in tchannel-crossdock/src/main/java/com/uber/tchannel/crossdock/behavior/trace/JSONHandler.java [37:63]
public Response callDownstream(Downstream downstream, InetAddress host, int port) throws Exception {
Request request = new Request(downstream.getServerRole(), downstream.getDownstream());
JsonRequest<Request> jsonRequest = new JsonRequest
.Builder<Request>(downstream.getServiceName(), ENDPOINT)
.setTimeout(5, TimeUnit.SECONDS)
.setBody(request)
.build();
logger.info("Sending JSON request {}", jsonRequest);
SubChannel subChannel = behavior.tchannel.makeSubChannel(downstream.getServiceName());
TFuture<JsonResponse<Response>> responsePromise = subChannel.send(
jsonRequest,
host,
port
);
JsonResponse<Response> jsonResponse = responsePromise.get();
try {
if (jsonResponse.isError()) {
throw new Exception("Error response: " + jsonResponse.getError());
}
return jsonResponse.getBody(Response.class);
} finally {
jsonResponse.release();
}
}