use of org.apache.servicecomb.codec.protobuf.utils.WrapSchema in project incubator-servicecomb-java-chassis by apache.
the class HighwayServerInvoke method sendResponse.
private void sendResponse(Map<String, String> context, Response response) {
ResponseHeader header = new ResponseHeader();
header.setStatusCode(response.getStatusCode());
header.setReasonPhrase(response.getReasonPhrase());
header.setContext(context);
header.setHeaders(response.getHeaders());
WrapSchema bodySchema = operationProtobuf.findResponseSchema(response.getStatusCode());
Object body = response.getResult();
if (response.isFailed()) {
body = ((InvocationException) body).getErrorData();
}
try {
Buffer respBuffer = HighwayCodec.encodeResponse(msgId, header, bodySchema, body, protobufFeature);
connection.write(respBuffer.getByteBuf());
} catch (Exception e) {
// 没招了,直接打日志
String msg = String.format("encode response failed, %s, msgId=%d", operationProtobuf.getOperationMeta().getMicroserviceQualifiedName(), msgId);
LOGGER.error(msg, e);
} finally {
invocation.onFinish(response);
}
}
Aggregations