jamesge commented on a change in pull request #972: Redis server protocol
URL: https://github.com/apache/incubator-brpc/pull/972#discussion_r358586373
##########
File path: src/brpc/policy/redis_protocol.cpp
##########
@@ -52,62 +54,202 @@ struct InputResponse : public InputMessageBase {
}
};
-// "Message" = "Response" as we only implement the client for redis.
+// This class is as parsing_context in socket.
+class RedisConnContext : public Destroyable {
+public:
+ RedisConnContext()
+ : redis_service(NULL)
+ , batched_size(0) {}
+
+ ~RedisConnContext();
+ // @Destroyable
+ void Destroy() override;
+
+ SocketId socket_id;
+ RedisService* redis_service;
+ // If user starts a transaction, handler_continue indicates the
+ // handler pointer that runs the transaction command.
+ std::unique_ptr<RedisCommandHandler> handler_continue;
+ // >0 if command handler is run in batched mode.
+ int batched_size;
+
+ RedisCommandParser parser;
+};
+
+static std::string ToLowercase(const std::string& command) {
+ std::string res;
+ res.resize(command.size());
+ std::transform(command.begin(), command.end(), res.begin(),
+ [](unsigned char c){ return std::tolower(c); });
+ return res;
+}
+
+int ConsumeCommand(RedisConnContext* ctx,
+ const std::unique_ptr<const char*[]>& commands,
+ int len, butil::Arena* arena,
+ bool is_last,
+ butil::IOBuf* sendbuf) {
+ RedisReply output(arena);
+ RedisCommandHandler::Result result = RedisCommandHandler::OK;
+ if (ctx->handler_continue) {
Review comment:
请统一一下"handler_continue"和"TransactionHandler"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]