| 549 | } |
| 550 | |
| 551 | void 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 |