Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(server): emulate readonly command #1004

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ void ServerFamily::Cluster(CmdArgList args, ConnectionContext* cntx) {
string_view sub_cmd = ArgS(args, 1);

if (!is_emulated_cluster_) {
return (*cntx)->SendError("CLUSTER commands demands the `cluster_mode` flag set to `emulated`");
return (*cntx)->SendError("CLUSTER commands requires --cluster_mode=emulated");
}

if (sub_cmd == "HELP") {
Expand All @@ -1203,7 +1203,7 @@ void ServerFamily::Cluster(CmdArgList args, ConnectionContext* cntx) {
" Return cluster configuration seen by node. Output format:",
" <id> <ip:port> <flags> <master> <pings> <pongs> <epoch> <link> <slot> ...",
"INFO",
+" Return information about the cluster",
" Return information about the cluster",
"HELP",
" Prints this help.",
};
Expand Down Expand Up @@ -1933,6 +1933,13 @@ void ServerFamily::Psync(CmdArgList args, ConnectionContext* cntx) {
SyncGeneric("?", 0, cntx); // full sync, ignore the request.
}

void ServerFamily::ReadOnly(CmdArgList args, ConnectionContext* cntx) {
if (!is_emulated_cluster_) {
return (*cntx)->SendError("READONLY command requires --cluster_mode=emulated");
}
(*cntx)->SendOk();
}

void ServerFamily::LastSave(CmdArgList args, ConnectionContext* cntx) {
time_t save_time;
{
Expand Down Expand Up @@ -2000,6 +2007,7 @@ void ServerFamily::Register(CommandRegistry* registry) {
<< CI{"SAVE", CO::ADMIN | CO::GLOBAL_TRANS, -1, 0, 0, 0}.HFUNC(Save)
<< CI{"SHUTDOWN", CO::ADMIN | CO::NOSCRIPT | CO::LOADING, 1, 0, 0, 0}.HFUNC(_Shutdown)
<< CI{"SLAVEOF", kReplicaOpts, 3, 0, 0, 0}.HFUNC(ReplicaOf)
<< CI{"READONLY", CO::READONLY, 1, 0, 0, 0}.HFUNC(ReadOnly)
<< CI{"REPLICAOF", kReplicaOpts, 3, 0, 0, 0}.HFUNC(ReplicaOf)
<< CI{"REPLCONF", CO::ADMIN | CO::LOADING, -1, 0, 0, 0}.HFUNC(ReplConf)
<< CI{"ROLE", CO::LOADING | CO::FAST | CO::NOSCRIPT, 1, 0, 0, 0}.HFUNC(Role)
Expand Down
1 change: 1 addition & 0 deletions src/server/server_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class ServerFamily {
void LastSave(CmdArgList args, ConnectionContext* cntx);
void Latency(CmdArgList args, ConnectionContext* cntx);
void Psync(CmdArgList args, ConnectionContext* cntx);
void ReadOnly(CmdArgList args, ConnectionContext* cntx);
void ReplicaOf(CmdArgList args, ConnectionContext* cntx);
void ReplConf(CmdArgList args, ConnectionContext* cntx);
void Role(CmdArgList args, ConnectionContext* cntx);
Expand Down