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

Function SerializeRedisRequest

src/brpc/policy/redis_protocol.cpp:273–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271void ProcessRedisRequest(InputMessageBase* msg_base) { }
272
273void SerializeRedisRequest(butil::IOBuf* buf,
274 Controller* cntl,
275 const google::protobuf::Message* request) {
276 if (request == NULL) {
277 return cntl->SetFailed(EREQUEST, "request is NULL");
278 }
279 if (request->GetDescriptor() != RedisRequest::descriptor()) {
280 return cntl->SetFailed(EREQUEST, "The request is not a RedisRequest");
281 }
282 const RedisRequest* rr = (const RedisRequest*)request;
283 // If redis byte size is zero, brpc call will fail with E22. Continuous E22 may cause E112 in the end.
284 // So set failed and return useful error message
285 if (GetProtobufByteSize(*rr) == 0) {
286 return cntl->SetFailed(EREQUEST, "request byte size is empty");
287 }
288 // We work around SerializeTo of pb which is just a placeholder.
289 if (!rr->SerializeTo(buf)) {
290 return cntl->SetFailed(EREQUEST, "Fail to serialize RedisRequest");
291 }
292 ControllerPrivateAccessor(cntl).set_pipelined_count(rr->command_size());
293 if (FLAGS_redis_verbose) {
294 LOG(INFO) << "\n[REDIS REQUEST] " << *rr;
295 }
296}
297
298void PackRedisRequest(butil::IOBuf* buf,
299 SocketMessage**,

Callers

nothing calls this directly

Calls 7

GetProtobufByteSizeFunction · 0.85
set_pipelined_countMethod · 0.80
command_sizeMethod · 0.80
SetFailedMethod · 0.45
GetDescriptorMethod · 0.45
SerializeToMethod · 0.45

Tested by

no test coverage detected