MCPcopy Create free account
hub / github.com/grpc/grpc-java / makeResponse

Method makeResponse

benchmarks/src/main/java/io/grpc/benchmarks/Utils.java:253–266  ·  view source on GitHub ↗

Construct a SimpleResponse for the given request.

(SimpleRequest request)

Source from the content-addressed store, hash-verified

251 * Construct a {@link SimpleResponse} for the given request.
252 */
253 public static SimpleResponse makeResponse(SimpleRequest request) {
254 if (request.getResponseSize() > 0) {
255 if (!Messages.PayloadType.COMPRESSABLE.equals(request.getResponseType())) {
256 throw Status.INTERNAL.augmentDescription("Error creating payload.").asRuntimeException();
257 }
258
259 ByteString body = ByteString.copyFrom(new byte[request.getResponseSize()]);
260 Messages.PayloadType type = request.getResponseType();
261
262 Payload payload = Payload.newBuilder().setType(type).setBody(body).build();
263 return SimpleResponse.newBuilder().setPayload(payload).build();
264 }
265 return SimpleResponse.getDefaultInstance();
266 }
267
268 /**
269 * Construct a {@link SimpleRequest} with the specified dimensions.

Callers 4

unaryCallMethod · 0.95
onNextMethod · 0.95
onCompletedMethod · 0.95
streamingFromServerMethod · 0.95

Calls 7

asRuntimeExceptionMethod · 0.80
augmentDescriptionMethod · 0.80
setTypeMethod · 0.80
buildMethod · 0.65
equalsMethod · 0.45
newBuilderMethod · 0.45
getDefaultInstanceMethod · 0.45

Tested by

no test coverage detected