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

Method Run

example/redis_c++/redis_server.cpp:174–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172 explicit AuthCommandHandler(RedisServiceImpl* rsimpl)
173 : _rsimpl(rsimpl) {}
174 brpc::RedisCommandHandlerResult Run(brpc::RedisConnContext* ctx,
175 const std::vector<butil::StringPiece>& args,
176 brpc::RedisReply* output,
177 bool /*flush_batched*/) override {
178 if (args.size() != 3ul) {
179 output->FormatError("Expect 2 args for 'auth', actually %lu", args.size()-1);
180 return brpc::REDIS_CMD_HANDLED;
181 }
182
183 const std::string db_name(args[1].data(), args[1].size());
184 const std::string password(args[2].data(), args[2].size());
185
186 if (_rsimpl->Auth(db_name, password)) {
187 output->SetStatus("OK");
188 auto auth_session = new AuthSession(db_name, password);
189 ctx->reset_session(auth_session);
190 } else {
191 output->FormatError("Invalid password for database '%s'", db_name.c_str());
192 }
193 return brpc::REDIS_CMD_HANDLED;
194 }
195
196private:
197 RedisServiceImpl* _rsimpl;

Callers

nothing calls this directly

Calls 7

FormatErrorMethod · 0.80
AuthMethod · 0.80
SetStatusMethod · 0.80
reset_sessionMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected