use of com.alibaba.nacos.api.grpc.auto.Metadata in project nacos by alibaba.
the class GrpcUtils method convert.
/**
* convert request to payload.
*
* @param request request.
* @return payload.
*/
public static Payload convert(Request request) {
Metadata newMeta = Metadata.newBuilder().setType(request.getClass().getSimpleName()).setClientIp(NetUtils.localIP()).putAllHeaders(request.getHeaders()).build();
request.clearHeaders();
String jsonString = toJson(request);
Payload.Builder builder = Payload.newBuilder();
return builder.setBody(Any.newBuilder().setValue(ByteString.copyFrom(jsonString, StandardCharsets.UTF_8))).setMetadata(newMeta).build();
}
Aggregations