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

 ##########
 File path: src/brpc/redis.h
 ##########
 @@ -209,7 +213,74 @@ 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. 
+class RedisService {
+public:
+    typedef std::unordered_map<std::string, RedisCommandHandler*> CommandMap;
+    virtual ~RedisService() {}
+    
+    // Call this function to register `handler` that can handle command `name`.
+    bool AddCommandHandler(const std::string& name, RedisCommandHandler* 
handler);
+
+    // This function should not be touched by user and used by brpc deverloper 
only.
+    RedisCommandHandler* FindCommandHandler(const std::string& name);
+private:
+    CommandMap _command_map;
+};
+
+// The Command handler for a redis request. User should impletement Run().
+class RedisCommandHandler {
+public:
+    enum Result {
+        OK = 0,
+        CONTINUE = 1,
 
 Review comment:
   这个需要和transaction handler对应下么?比如叫BEGIN_TRANSACTION或NEW_TRANSACTION

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