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

Function SerializeNsheadRequest

src/brpc/policy/nshead_protocol.cpp:400–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398}
399
400void SerializeNsheadRequest(butil::IOBuf* request_buf, Controller* cntl,
401 const google::protobuf::Message* req_base) {
402 if (req_base == NULL) {
403 return cntl->SetFailed(EREQUEST, "request is NULL");
404 }
405 if (req_base->GetDescriptor() != NsheadMessage::descriptor()) {
406 return cntl->SetFailed(EINVAL, "Type of request must be NsheadMessage");
407 }
408 if (cntl->response() != NULL &&
409 cntl->response()->GetDescriptor() != NsheadMessage::descriptor()) {
410 return cntl->SetFailed(EINVAL, "Type of response must be NsheadMessage");
411 }
412 const NsheadMessage* req = (const NsheadMessage*)req_base;
413 nshead_t nshead = req->head;
414 if (cntl->has_log_id()) {
415 nshead.log_id = cntl->log_id();
416 }
417 nshead.magic_num = NSHEAD_MAGICNUM;
418 nshead.body_len = req->body.size();
419 request_buf->append(&nshead, sizeof(nshead));
420 request_buf->append(req->body);
421}
422
423void PackNsheadRequest(
424 butil::IOBuf* packet_buf,

Callers

nothing calls this directly

Calls 7

responseMethod · 0.80
has_log_idMethod · 0.80
SetFailedMethod · 0.45
GetDescriptorMethod · 0.45
log_idMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected