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

 ##########
 File path: src/brpc/redis_message.h
 ##########
 @@ -30,32 +30,39 @@
 namespace brpc {
 
 // Different types of replies.
-enum RedisReplyType {
-    REDIS_REPLY_STRING = 1,  // Bulk String
-    REDIS_REPLY_ARRAY = 2,
-    REDIS_REPLY_INTEGER = 3,
-    REDIS_REPLY_NIL = 4,
-    REDIS_REPLY_STATUS = 5,  // Simple String
-    REDIS_REPLY_ERROR = 6
+enum RedisMessageType {
+    REDIS_MESSAGE_STRING = 1,  // Bulk String
+    REDIS_MESSAGE_ARRAY = 2,
+    REDIS_MESSAGE_INTEGER = 3,
+    REDIS_MESSAGE_NIL = 4,
+    REDIS_MESSAGE_STATUS = 5,  // Simple String
+    REDIS_MESSAGE_ERROR = 6
 };
 
-const char* RedisReplyTypeToString(RedisReplyType);
+const char* RedisMessageTypeToString(RedisMessageType);
 
 // A reply from redis-server.
-class RedisReply {
+class RedisMessage {
 public:
     // A default constructed reply is a nil.
-    RedisReply();
+    RedisMessage();
 
     // Type of the reply.
-    RedisReplyType type() const { return _type; }
+    RedisMessageType type() const { return _type; }
     
     bool is_nil() const;     // True if the reply is a (redis) nil.
     bool is_integer() const; // True if the reply is an integer.
     bool is_error() const;   // True if the reply is an error.
     bool is_string() const;  // True if the reply is a string.
     bool is_array() const;   // True if the reply is an array.
 
+    bool set_nil_string();  // "$-1\r\n"
+    bool set_array(int size, butil::Arena* arena);  // size == -1 means nil 
array("*-1\r\n")
+    bool set_status(const std::string& str, butil::Arena* arena);
+    bool set_error(const std::string& str, butil::Arena* arena);
+    bool set_integer(int64_t value);
+    bool set_bulk_string(const std::string& str, butil::Arena* arena);
 
 Review comment:
   不符合编码规范。全小写的意思是这个函数很轻量,大概率inline,可以随便调用,这里的set显然不是。

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to