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

Function PackSofaRequest

src/brpc/policy/sofa_pbrpc_protocol.cpp:551–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551void PackSofaRequest(butil::IOBuf* req_buf,
552 SocketMessage**,
553 uint64_t correlation_id,
554 const google::protobuf::MethodDescriptor* method,
555 Controller* cntl,
556 const butil::IOBuf& req_body,
557 const Authenticator* /*not supported*/) {
558 if (!cntl->request_attachment().empty()) {
559 LOG(WARNING) << "sofa-pbrpc does not support attachment, "
560 "your request_attachment will not be sent";
561 }
562 SofaRpcMeta meta;
563 meta.set_type(SofaRpcMeta::REQUEST);
564 meta.set_sequence_id(correlation_id);
565 if (method) {
566 meta.set_method(method->full_name());
567 meta.set_compress_type(CompressType2Sofa(cntl->request_compress_type()));
568 } else if (cntl->sampled_request()) {
569 // Replaying.
570 meta.set_method(cntl->sampled_request()->meta.method_name());
571 meta.set_compress_type(
572 CompressType2Sofa(cntl->sampled_request()->meta.compress_type()));
573 } else {
574 return cntl->SetFailed(ENOMETHOD, "method is NULL");
575 }
576
577 SerializeSofaHeaderAndMeta(req_buf, meta, req_body.size());
578 req_buf->append(req_body);
579}
580
581} // namespace policy
582} // namespace brpc

Callers 2

TestSofaCompressMethod · 0.85
TEST_FFunction · 0.85

Calls 10

CompressType2SofaFunction · 0.85
request_compress_typeMethod · 0.80
sampled_requestMethod · 0.80
emptyMethod · 0.45
set_typeMethod · 0.45
set_methodMethod · 0.45
SetFailedMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by 2

TestSofaCompressMethod · 0.68
TEST_FFunction · 0.68