MCPcopy Create free account
hub / github.com/apache/brpc / ProtoMessageToProtoJson

Function ProtoMessageToProtoJson

src/brpc/policy/http_rpc_protocol.cpp:334–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334static bool ProtoMessageToProtoJson(const google::protobuf::Message& message,
335 butil::IOBufAsZeroCopyOutputStream* wrapper,
336 Controller* cntl, int error_code) {
337 json2pb::Pb2ProtoJsonOptions options;
338 AlwaysPrintPrimitiveFields(options) = cntl->has_always_print_primitive_fields();
339 options.always_print_enums_as_ints = FLAGS_pb_enum_as_number;
340 std::string error;
341 bool ok = json2pb::ProtoMessageToProtoJson(message, wrapper, options, &error);
342 if (!ok) {
343 cntl->SetFailed(error_code, "Fail to convert %s to proto-json: %s",
344 butil::EnsureString(message.GetDescriptor()->full_name()).c_str(), error.c_str());
345 }
346 return ok;
347}
348
349void ProcessHttpResponse(InputMessageBase* msg) {
350 const int64_t start_parse_us = butil::cpuwide_time_us();

Callers 3

SerializeHttpRequestFunction · 0.70
~HttpResponseSenderMethod · 0.70
SerializeRpcMessageFunction · 0.70

Calls 5

EnsureStringFunction · 0.85
SetFailedMethod · 0.45
c_strMethod · 0.45
GetDescriptorMethod · 0.45

Tested by

no test coverage detected