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

Function SerializeResponse

src/brpc/policy/baidu_rpc_protocol.cpp:218–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218static bool SerializeResponse(const google::protobuf::Message& res,
219 Controller& cntl, butil::IOBuf& buf) {
220 if (res.GetDescriptor() == SerializedResponse::descriptor()) {
221 buf.swap(((SerializedResponse&)res).serialized_data());
222 return true;
223 }
224
225 if (!res.IsInitialized()) {
226 cntl.SetFailed(ERESPONSE, "Missing required fields in response: %s",
227 res.InitializationErrorString().c_str());
228 return false;
229 }
230
231 ContentType content_type = cntl.response_content_type();
232 CompressType compress_type = cntl.response_compress_type();
233 ChecksumType checksum_type = cntl.response_checksum_type();
234 if (!SerializeRpcMessage(res, cntl, content_type, compress_type,
235 checksum_type, &buf)) {
236 cntl.SetFailed(ERESPONSE,
237 "Fail to serialize response=%s, "
238 "ContentType=%s, CompressType=%s, ChecksumType=%s",
239 butil::EnsureString(res.GetDescriptor()->full_name()).c_str(),
240 ContentTypeToCStr(content_type),
241 CompressTypeToCStr(compress_type),
242 ChecksumTypeToCStr(checksum_type));
243 return false;
244 }
245 return true;
246}
247
248namespace {
249struct BaiduProxyPBMessages : public RpcPBMessages {

Callers 1

Calls 14

SerializeRpcMessageFunction · 0.85
EnsureStringFunction · 0.85
ContentTypeToCStrFunction · 0.85
CompressTypeToCStrFunction · 0.85
ChecksumTypeToCStrFunction · 0.85
response_content_typeMethod · 0.80
GetDescriptorMethod · 0.45
swapMethod · 0.45
IsInitializedMethod · 0.45

Tested by

no test coverage detected