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

Method ParseRequest

src/brpc/redis_cluster.cpp:324–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324bool RedisClusterChannel::ParseRequest(const RedisRequest& request,
325 std::vector<ParsedCommand>* commands,
326 Controller* cntl) const {
327 commands->clear();
328
329 butil::IOBuf serialized;
330 if (!request.SerializeTo(&serialized)) {
331 cntl->SetFailed(EREQUEST, "Fail to serialize redis request");
332 return false;
333 }
334
335 RedisCommandParser parser;
336 butil::Arena arena;
337
338 while (!serialized.empty()) {
339 std::vector<butil::StringPiece> args;
340 ParseError err = parser.Consume(serialized, &args, &arena);
341 if (err != PARSE_OK) {
342 cntl->SetFailed(EREQUEST, "Fail to parse redis request (err=%d)", err);
343 return false;
344 }
345 ParsedCommand cmd;
346 cmd.args.reserve(args.size());
347 for (size_t i = 0; i < args.size(); ++i) {
348 cmd.args.push_back(args[i].as_string());
349 }
350 commands->push_back(cmd);
351 }
352 return true;
353}
354
355bool RedisClusterChannel::ExecuteCommand(const ParsedCommand& cmd,
356 butil::IOBuf* encoded_reply,

Callers

nothing calls this directly

Calls 9

clearMethod · 0.45
SerializeToMethod · 0.45
SetFailedMethod · 0.45
emptyMethod · 0.45
ConsumeMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
as_stringMethod · 0.45

Tested by

no test coverage detected