jamesge commented on a change in pull request #972: Redis server protocol
URL: https://github.com/apache/incubator-brpc/pull/972#discussion_r351583191
 
 

 ##########
 File path: src/brpc/redis.h
 ##########
 @@ -209,7 +212,51 @@ class RedisResponse : public ::google::protobuf::Message {
 std::ostream& operator<<(std::ostream& os, const RedisRequest&);
 std::ostream& operator<<(std::ostream& os, const RedisResponse&);
 
-} // namespace brpc
+class RedisCommandHandler;
+
+// Implement this class and assign an instance to ServerOption.redis_service
+// to enable redis support. To support a particular command, you should 
implement
+// the corresponding handler and call AddCommandHandler to install it.
+class RedisService {
+public:
+    typedef std::unordered_map<std::string, 
std::shared_ptr<RedisCommandHandler>> CommandMap;
+    virtual ~RedisService() {}
+
+    bool AddCommandHandler(const std::string& name, RedisCommandHandler* 
handler);
+    void CloneCommandMap(CommandMap* map);
+private:
+    CommandMap _command_map;
+};
+
+// The handler for a redis command. Run() and New() should be implemented
+// by user.
+//
+// For Run(), `args` is the redis command argument. For example,
 
 Review comment:
   这段放到Run前面去,可以省略"For Run()"。
   注释是给用户看的。对于一个接口,至少要提及框架什么时候会调用,以及接口返回什么后框架会做哪些工作。这段注释均没有提到。
   在redis的场景中,还有一个特殊点在于同一连接中多个command是串行执行的,这是对用户很重要,同样没有提及。

----------------------------------------------------------------
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]

Reply via email to