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

Method SerializeResponseToIOBuf

src/brpc/policy/nshead_mcpack_protocol.cpp:72–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void NsheadMcpackAdaptor::SerializeResponseToIOBuf(
73 const NsheadMeta&, Controller* cntl,
74 const google::protobuf::Message* pb_res, NsheadMessage* raw_res) const {
75 if (cntl->Failed()) {
76 cntl->CloseConnection("Close connection due to previous error");
77 return;
78 }
79 CompressType type = cntl->response_compress_type();
80 if (type != COMPRESS_TYPE_NONE) {
81 LOG(WARNING) << "nshead_mcpack protocol doesn't support compression";
82 type = COMPRESS_TYPE_NONE;
83 }
84
85 if (pb_res == NULL) {
86 cntl->CloseConnection("response was not created yet");
87 return;
88 }
89
90 const std::string msg_name = butil::EnsureString(pb_res->GetDescriptor()->full_name());
91 mcpack2pb::MessageHandler handler = mcpack2pb::find_message_handler(msg_name);
92 if (!handler.serialize_to_iobuf(*pb_res, &raw_res->body,
93 ::mcpack2pb::FORMAT_MCPACK_V2)) {
94 cntl->CloseConnection("Fail to serialize %s", msg_name.c_str());
95 return;
96 }
97}
98
99void ProcessNsheadMcpackResponse(InputMessageBase* msg_base) {
100 const int64_t start_parse_us = butil::cpuwide_time_us();

Callers

nothing calls this directly

Calls 8

EnsureStringFunction · 0.85
find_message_handlerFunction · 0.85
CloseConnectionMethod · 0.80
serialize_to_iobufMethod · 0.80
FailedMethod · 0.45
GetDescriptorMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected