/** * 通过响应透传数据 * * @param context RpcInvokeContext * @param response 响应 */ public static void carryWithResponse(RpcInvokeContext context, SofaResponse response) { if (context != null) { Map<String, String> responseBaggage = context.getAllResponseBaggage(); if (CommonUtils.isNotEmpty(responseBaggage)) { String prefix = RemotingConstants.RPC_RESPONSE_BAGGAGE + "."; for (Map.Entry<String, String> entry : responseBaggage.entrySet()) { response.addResponseProp(prefix + entry.getKey(), entry.getValue()); } } } }
/** * 通过响应透传数据 * * @param context RpcInvokeContext * @param response 响应 */ public static void carryWithResponse(RpcInvokeContext context, SofaResponse response) { if (context != null) { Map<String, String> responseBaggage = context.getAllResponseBaggage(); if (CommonUtils.isNotEmpty(responseBaggage)) { String prefix = RemotingConstants.RPC_RESPONSE_BAGGAGE + "."; for (Map.Entry<String, String> entry : responseBaggage.entrySet()) { response.addResponseProp(prefix + entry.getKey(), entry.getValue()); } } } }
@Override public <Response extends ResponseCommand> boolean serializeHeader(Response response) throws SerializationException { if (response instanceof RpcResponseCommand) { RpcInternalContext.getContext().getStopWatch().tick(); Object responseObject = ((RpcResponseCommand) response).getResponseObject(); if (responseObject instanceof SofaResponse) { SofaResponse sofaResponse = (SofaResponse) responseObject; if (sofaResponse.isError() || sofaResponse.getAppResponse() instanceof Throwable) { sofaResponse.addResponseProp(RemotingConstants.HEAD_RESPONSE_ERROR, StringUtils.TRUE); } response.setHeader(mapSerializer.encode(sofaResponse.getResponseProps())); } return true; } return false; }
@Override public <Response extends ResponseCommand> boolean serializeHeader(Response response) throws SerializationException { if (response instanceof RpcResponseCommand) { RpcInternalContext.getContext().getStopWatch().tick(); Object responseObject = ((RpcResponseCommand) response).getResponseObject(); if (responseObject instanceof SofaResponse) { SofaResponse sofaResponse = (SofaResponse) responseObject; if (sofaResponse.isError() || sofaResponse.getAppResponse() instanceof Throwable) { sofaResponse.addResponseProp(RemotingConstants.HEAD_RESPONSE_ERROR, StringUtils.TRUE); } response.setHeader(mapSerializer.encode(sofaResponse.getResponseProps())); } return true; } return false; }
/** * 通过响应透传数据 * * @param context RpcInvokeContext * @param response 响应 */ public static void carryWithResponse(RpcInvokeContext context, SofaResponse response) { if (context != null) { Map<String, String> responseBaggage = context.getAllResponseBaggage(); if (CommonUtils.isNotEmpty(responseBaggage)) { String prefix = RemotingConstants.RPC_RESPONSE_BAGGAGE + "."; for (Map.Entry<String, String> entry : responseBaggage.entrySet()) { response.addResponseProp(prefix + entry.getKey(), entry.getValue()); } } } }
@Override public <Response extends ResponseCommand> boolean serializeHeader(Response response) throws SerializationException { if (response instanceof RpcResponseCommand) { RpcInternalContext.getContext().getStopWatch().tick(); Object responseObject = ((RpcResponseCommand) response).getResponseObject(); if (responseObject instanceof SofaResponse) { SofaResponse sofaResponse = (SofaResponse) responseObject; if (sofaResponse.isError() || sofaResponse.getAppResponse() instanceof Throwable) { sofaResponse.addResponseProp(RemotingConstants.HEAD_RESPONSE_ERROR, StringUtils.TRUE); } response.setHeader(mapSerializer.encode(sofaResponse.getResponseProps())); } return true; } return false; }