Commit 458c45ef authored by zhujiashun's avatar zhujiashun

redis_server_protocol: change para name of Commandhandler from is_last to flush_back

parent 227f5881
......@@ -80,12 +80,12 @@ int ConsumeCommand(RedisConnContext* ctx,
const std::vector<const char*>& commands,
const std::string& next_command,
butil::Arena* arena,
bool is_last,
bool flush_back,
butil::IOBufAppender* appender) {
RedisReply output(arena);
RedisCommandHandler::Result result = RedisCommandHandler::OK;
if (ctx->transaction_handler) {
result = ctx->transaction_handler->Run(commands, &output, is_last);
result = ctx->transaction_handler->Run(commands, &output, flush_back);
if (result == RedisCommandHandler::OK) {
ctx->transaction_handler.reset(NULL);
} else if (result == RedisCommandHandler::BATCHED) {
......@@ -102,12 +102,12 @@ int ConsumeCommand(RedisConnContext* ctx,
RedisCommandHandler* next_ch =
ctx->redis_service->FindCommandHandler(next_command);
if (next_ch && next_ch->TransactionMarker()) {
is_last = true;
flush_back = true;
}
result = ch->Run(commands, &output, is_last);
result = ch->Run(commands, &output, flush_back);
if (result == RedisCommandHandler::CONTINUE) {
if (ctx->batched_size != 0) {
LOG(ERROR) << "Do you forget to return OK when is_last is true?";
LOG(ERROR) << "Do you forget to return OK when flush_back is true?";
return -1;
}
ctx->transaction_handler.reset(ch->NewTransactionHandler());
......
......@@ -248,9 +248,9 @@ public:
// corresponds to args[0]=="set", args[1]=="somekey" and args[2]=="somevalue".
// `output', which should be filled by user, is the content that sent to client side.
// Read brpc/src/redis_reply.h for more usage.
// `is_last' indicates whether the commands is the last command of this batch. If user
// `flush_back' indicates whether the commands is the last command of this batch. If user
// want to do some batch processing, user should buffer the command and return
// RedisCommandHandler::BATCHED. Once `is_last' is true, run all the commands,
// RedisCommandHandler::BATCHED. Once `flush_back' is true, run all the commands,
// set `output' to be an array in which every element is the result of batched
// commands and return RedisCommandHandler::OK.
//
......@@ -261,7 +261,7 @@ public:
// it returns RedisCommandHandler::OK. Read the comment below.
virtual RedisCommandHandler::Result Run(const std::vector<const char*>& args,
brpc::RedisReply* output,
bool is_last) = 0;
bool flush_back) = 0;
// The Run() returns CONTINUE for "multi", which makes brpc call this method to
// create a transaction_handler to process following commands until transaction_handler
......
......@@ -798,8 +798,8 @@ public:
: _batch_count(0) {}
brpc::RedisCommandHandler::Result OnBatched(const std::vector<const char*> args,
brpc::RedisReply* output, bool is_last) {
if (_batched_command.empty() && is_last) {
brpc::RedisReply* output, bool flush_back) {
if (_batched_command.empty() && flush_back) {
if (strcmp(args[0], "set") == 0) {
DoSet(args[1], args[2], output);
} else if (strcmp(args[0], "get") == 0) {
......@@ -812,7 +812,7 @@ public:
comm.push_back(args[i]);
}
_batched_command.push_back(comm);
if (is_last) {
if (flush_back) {
output->SetArray(_batched_command.size());
for (int i = 0; i < (int)_batched_command.size(); ++i) {
if (_batched_command[i][0] == "set") {
......@@ -856,13 +856,13 @@ public:
brpc::RedisCommandHandler::Result Run(const std::vector<const char*>& args,
brpc::RedisReply* output,
bool is_last) {
bool flush_back) {
if (args.size() < 3) {
output->SetError("ERR wrong number of arguments for 'set' command");
return brpc::RedisCommandHandler::OK;
}
if (_batch_process) {
return rs->OnBatched(args, output, is_last);
return rs->OnBatched(args, output, flush_back);
} else {
DoSet(args[1], args[2], output);
return brpc::RedisCommandHandler::OK;
......@@ -887,13 +887,13 @@ public:
brpc::RedisCommandHandler::Result Run(const std::vector<const char*>& args,
brpc::RedisReply* output,
bool is_last) {
bool flush_back) {
if (args.size() < 2) {
output->SetError("ERR wrong number of arguments for 'get' command");
return brpc::RedisCommandHandler::OK;
}
if (_batch_process) {
return rs->OnBatched(args, output, is_last);
return rs->OnBatched(args, output, flush_back);
} else {
DoGet(args[1], output);
return brpc::RedisCommandHandler::OK;
......@@ -920,7 +920,7 @@ public:
brpc::RedisCommandHandler::Result Run(const std::vector<const char*>& args,
brpc::RedisReply* output,
bool is_last) {
bool flush_back) {
if (args.size() < 2) {
output->SetError("ERR wrong number of arguments for 'incr' command");
return brpc::RedisCommandHandler::OK;
......@@ -1034,7 +1034,7 @@ public:
brpc::RedisCommandHandler::Result Run(const std::vector<const char*>& args,
brpc::RedisReply* output,
bool is_last) {
bool flush_back) {
output->SetStatus("OK");
return brpc::RedisCommandHandler::CONTINUE;
}
......@@ -1050,7 +1050,7 @@ public:
public:
brpc::RedisCommandHandler::Result Run(const std::vector<const char*>& args,
brpc::RedisReply* output,
bool is_last) {
bool flush_back) {
if (strcmp(args[0], "multi") == 0) {
output->SetError("ERR duplicate multi");
return brpc::RedisCommandHandler::CONTINUE;
......
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