use of com.quancheng.saluki.core.grpc.exception.RpcServiceException in project tesla by linking12.
the class DynamicGrpcClient method doRemoteCall.
@Override
public String doRemoteCall(final FilterRpcDO rpcDo, final String jsonInput) {
try {
final String serviceName = rpcDo.getServiceName();
final String methodName = rpcDo.getMethodName();
final String group = rpcDo.getServiceGroup();
final String version = rpcDo.getServiceVersion();
Pair<Descriptor, Descriptor> inOutType = ProtobufUtil.resolveServiceInputOutputType(rpcDo);
Descriptor inPutType = inOutType.getLeft();
Descriptor outPutType = inOutType.getRight();
MethodDescriptor<DynamicMessage, DynamicMessage> methodDesc = this.createGrpcMethodDescriptor(serviceName, methodName, inPutType, outPutType);
DynamicMessage message = this.createGrpcDynamicMessage(inPutType, jsonInput);
Message response = (Message) genricService.$invoke(serviceName, group, version, methodName, methodDesc, message);
return JSON2PROTOBUF.printToString(response);
} catch (IOException e) {
throw new RpcServiceException(String.format("json covert to DynamicMessage failed! the json is :%s, the protobuf type is: %s", jsonInput), e);
} catch (Throwable e) {
throw new RpcFrameworkException(String.format("service definition is wrong,please check the proto file you update,service is %s, method is %s", rpcDo.getServiceName(), rpcDo.getMethodName()), e);
}
}
Aggregations