Commit 97fde2e1 authored by zhujiashun's avatar zhujiashun

redis_server_protocol: refine code

parent bd7522b6
...@@ -107,7 +107,6 @@ public: ...@@ -107,7 +107,6 @@ public:
bthread::ExecutionQueueId<ExecutionQueueContext*> queue; bthread::ExecutionQueueId<ExecutionQueueContext*> queue;
}; };
// "Message" = "Response" as we only implement the client for redis.
ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket, ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
bool read_eof, const void* arg) { bool read_eof, const void* arg) {
if (read_eof || source->empty()) { if (read_eof || source->empty()) {
......
...@@ -35,7 +35,7 @@ void ProcessRedisResponse(InputMessageBase* msg); ...@@ -35,7 +35,7 @@ void ProcessRedisResponse(InputMessageBase* msg);
// Actions to a redis request, which is left unimplemented. // Actions to a redis request, which is left unimplemented.
// All requests are processed in execution queue pushed in // All requests are processed in execution queue pushed in
// the parse process. // the parsing process.
void ProcessRedisRequest(InputMessageBase* msg); void ProcessRedisRequest(InputMessageBase* msg);
// Serialize a redis request. // Serialize a redis request.
......
...@@ -162,7 +162,7 @@ inline RedisMessage::RedisMessage() ...@@ -162,7 +162,7 @@ inline RedisMessage::RedisMessage()
inline bool RedisMessage::is_nil() const { inline bool RedisMessage::is_nil() const {
return (_type == REDIS_MESSAGE_NIL) || return (_type == REDIS_MESSAGE_NIL) ||
((_type == REDIS_MESSAGE_STRING || _type == REDIS_MESSAGE_ARRAY) && ((_type == REDIS_MESSAGE_STRING || _type == REDIS_MESSAGE_ARRAY) &&
_length == uint32_t(-1)); _length == npos);
} }
inline bool RedisMessage::is_error() const { return _type == REDIS_MESSAGE_ERROR; } inline bool RedisMessage::is_error() const { return _type == REDIS_MESSAGE_ERROR; }
inline bool RedisMessage::is_integer() const { return _type == REDIS_MESSAGE_INTEGER; } inline bool RedisMessage::is_integer() const { return _type == REDIS_MESSAGE_INTEGER; }
......
...@@ -142,7 +142,8 @@ ServerOptions::ServerOptions() ...@@ -142,7 +142,8 @@ ServerOptions::ServerOptions()
, has_builtin_services(true) , has_builtin_services(true)
, http_master_service(NULL) , http_master_service(NULL)
, health_reporter(NULL) , health_reporter(NULL)
, rtmp_service(NULL) { , rtmp_service(NULL)
, redis_service(NULL) {
if (s_ncore > 0) { if (s_ncore > 0) {
num_threads = s_ncore + 1; num_threads = s_ncore + 1;
} }
...@@ -1588,7 +1589,8 @@ void Server::GenerateVersionIfNeeded() { ...@@ -1588,7 +1589,8 @@ void Server::GenerateVersionIfNeeded() {
if (!_version.empty()) { if (!_version.empty()) {
return; return;
} }
int extra_count = !!_options.nshead_service + !!_options.rtmp_service + !!_options.thrift_service; int extra_count = !!_options.nshead_service + !!_options.rtmp_service +
!!_options.thrift_service + !!_options.redis_service;
_version.reserve((extra_count + service_count()) * 20); _version.reserve((extra_count + service_count()) * 20);
for (ServiceMap::const_iterator it = _fullname_service_map.begin(); for (ServiceMap::const_iterator it = _fullname_service_map.begin();
it != _fullname_service_map.end(); ++it) { it != _fullname_service_map.end(); ++it) {
...@@ -1621,6 +1623,13 @@ void Server::GenerateVersionIfNeeded() { ...@@ -1621,6 +1623,13 @@ void Server::GenerateVersionIfNeeded() {
} }
_version.append(butil::class_name_str(*_options.rtmp_service)); _version.append(butil::class_name_str(*_options.rtmp_service));
} }
if (_options.redis_service) {
if (!_version.empty()) {
_version.push_back('+');
}
_version.append(butil::class_name_str(*_options.redis_service));
}
} }
static std::string ExpandPath(const std::string &path) { static std::string ExpandPath(const std::string &path) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment