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

Method Run

test/brpc_redis_unittest.cpp:1202–1231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1200 class MultiTransactionHandler : public brpc::RedisCommandHandler {
1201 public:
1202 brpc::RedisCommandHandlerResult Run(const std::vector<butil::StringPiece>& args,
1203 brpc::RedisReply* output,
1204 bool flush_batched) override {
1205 if (args[0] == "multi") {
1206 output->SetError("ERR duplicate multi");
1207 return brpc::REDIS_CMD_CONTINUE;
1208 }
1209 if (args[0] != "exec") {
1210 std::vector<std::string> comm;
1211 for (int i = 0; i < (int)args.size(); ++i) {
1212 comm.push_back(args[i].as_string());
1213 }
1214 _commands.push_back(comm);
1215 output->SetStatus("QUEUED");
1216 return brpc::REDIS_CMD_CONTINUE;
1217 }
1218 output->SetArray(_commands.size());
1219 s_mutex.lock();
1220 for (size_t i = 0; i < _commands.size(); ++i) {
1221 if (_commands[i][0] == "incr") {
1222 int64_t value;
1223 value = ++int_map[_commands[i][1]];
1224 (*output)[i].SetInteger(value);
1225 } else {
1226 (*output)[i].SetStatus("unknown command");
1227 }
1228 }
1229 s_mutex.unlock();
1230 return brpc::REDIS_CMD_HANDLED;
1231 }
1232 private:
1233 std::vector<std::vector<std::string> > _commands;
1234 };

Callers

nothing calls this directly

Calls 9

SetStatusMethod · 0.80
SetArrayMethod · 0.80
SetIntegerMethod · 0.80
SetErrorMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
as_stringMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected