Commit 0c96ecef authored by zhujiashun's avatar zhujiashun

redis_server_protocol: rename RedisReply to RedisMessage

parent 978814fe
......@@ -54,7 +54,7 @@ struct InputResponse : public InputMessageBase {
};
struct ExecutionQueueContext {
RedisReply message;
RedisMessage message;
SocketId socket_id;
butil::Arena arena;
};
......@@ -72,7 +72,7 @@ int Consume(void* meta, bthread::TaskIterator<ExecutionQueueContext*>& iter) {
LOG(WARNING) << "Fail to address redis socket";
continue;
}
RedisReply output;
RedisMessage output;
conn->OnRedisMessage(ctx->message, &output, &ctx->arena);
butil::IOBuf sendbuf;
output.SerializeToIOBuf(&sendbuf);
......@@ -132,7 +132,7 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
socket->reset_parsing_context(ctx);
}
std::unique_ptr<ExecutionQueueContext> task(new ExecutionQueueContext);
RedisReply message;
RedisMessage message;
ParseError err = message.ConsumePartialIOBuf(*source, &task->arena);
if (err != PARSE_OK) {
return MakeParseError(err);
......@@ -178,7 +178,7 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
if (pi.with_auth) {
if (msg->response.reply_size() != 1 ||
!(msg->response.reply(0).type() == brpc::REDIS_REPLY_STATUS &&
!(msg->response.reply(0).type() == brpc::REDIS_MESSAGE_STATUS &&
msg->response.reply(0).data().compare("OK") == 0)) {
LOG(ERROR) << "Redis Auth failed: " << msg->response;
return MakeParseError(PARSE_ERROR_NO_RESOURCE,
......
......@@ -322,10 +322,10 @@ void RedisResponse::MergeFrom(const RedisResponse& from) {
_nreply = new_nreply;
return;
}
RedisReply* new_others =
(RedisReply*)_arena.allocate(sizeof(RedisReply) * (new_nreply - 1));
RedisMessage* new_others =
(RedisMessage*)_arena.allocate(sizeof(RedisMessage) * (new_nreply - 1));
for (int i = 0; i < new_nreply - 1; ++i) {
new (new_others + i) RedisReply;
new (new_others + i) RedisMessage;
}
int new_other_index = 0;
for (int i = 1; i < _nreply; ++i) {
......@@ -394,14 +394,14 @@ ParseError RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count
}
if (reply_count > 1) {
if (_other_replies == NULL) {
_other_replies = (RedisReply*)_arena.allocate(
sizeof(RedisReply) * (reply_count - 1));
_other_replies = (RedisMessage*)_arena.allocate(
sizeof(RedisMessage) * (reply_count - 1));
if (_other_replies == NULL) {
LOG(ERROR) << "Fail to allocate RedisReply[" << reply_count -1 << "]";
LOG(ERROR) << "Fail to allocate RedisMessage[" << reply_count -1 << "]";
return PARSE_ERROR_ABSOLUTELY_WRONG;
}
for (int i = 0; i < reply_count - 1; ++i) {
new (&_other_replies[i]) RedisReply;
new (&_other_replies[i]) RedisMessage;
}
}
for (int i = reply_size(); i < reply_count; ++i) {
......
......@@ -25,7 +25,7 @@
#include "butil/strings/string_piece.h"
#include "butil/arena.h"
#include "brpc/proto_base.pb.h"
#include "brpc/redis_reply.h"
#include "brpc/redis_message.h"
#include "brpc/parse_result.h"
namespace brpc {
......@@ -157,11 +157,11 @@ public:
int reply_size() const { return _nreply; }
// Get index-th reply. If index is out-of-bound, nil reply is returned.
const RedisReply& reply(int index) const {
const RedisMessage& reply(int index) const {
if (index < reply_size()) {
return (index == 0 ? _first_reply : _other_replies[index - 1]);
}
static RedisReply redis_nil;
static RedisMessage redis_nil;
return redis_nil;
}
......@@ -199,8 +199,8 @@ private:
void SharedDtor();
void SetCachedSize(int size) const;
RedisReply _first_reply;
RedisReply* _other_replies;
RedisMessage _first_reply;
RedisMessage* _other_replies;
butil::Arena _arena;
int _nreply;
mutable int _cached_size_;
......@@ -212,8 +212,8 @@ std::ostream& operator<<(std::ostream& os, const RedisResponse&);
class RedisConnection {
public:
virtual ~RedisConnection() {}
virtual void OnRedisMessage(const RedisReply& message,
RedisReply* output, butil::Arena* arena) = 0;
virtual void OnRedisMessage(const RedisMessage& message,
RedisMessage* output, butil::Arena* arena) = 0;
};
class RedisService {
......
This diff is collapsed.
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