1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

fix: mark pubusb commands as unsupported for cluster (#3767)

This commit is contained in:
Borys 2024-09-23 12:59:13 +03:00 committed by GitHub
parent 9c49aee43d
commit 9303591010
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View file

@ -589,6 +589,19 @@ TEST_F(ClusterFamilyTest, ClusterModeSelectNotAllowed) {
EXPECT_EQ(Run({"select", "0"}), "OK");
}
TEST_F(ClusterFamilyTest, ClusterModePubSubNotAllowed) {
EXPECT_THAT(Run({"PUBLISH", "ch", "message"}),
ErrArg("PUBLISH is not supported in cluster mode yet"));
EXPECT_THAT(Run({"SUBSCRIBE", "ch"}), ErrArg("SUBSCRIBE is not supported in cluster mode yet"));
EXPECT_THAT(Run({"UNSUBSCRIBE", "ch"}),
ErrArg("UNSUBSCRIBE is not supported in cluster mode yet"));
EXPECT_THAT(Run({"PSUBSCRIBE", "ch?"}),
ErrArg("PSUBSCRIBE is not supported in cluster mode yet"));
EXPECT_THAT(Run({"PUNSUBSCRIBE", "ch?"}),
ErrArg("PUNSUBSCRIBE is not supported in cluster mode yet"));
EXPECT_THAT(Run({"PUBSUB", "CHANNELS"}), ErrArg("PUBSUB is not supported in cluster mode yet"));
}
TEST_F(ClusterFamilyTest, ClusterFirstConfigCallDropsEntriesNotOwnedByNode) {
InitWithDbFilename();

View file

@ -2354,6 +2354,9 @@ void Service::Exec(CmdArgList args, ConnectionContext* cntx) {
}
void Service::Publish(CmdArgList args, ConnectionContext* cntx) {
if (cluster::IsClusterEnabled()) {
return cntx->SendError("PUBLISH is not supported in cluster mode yet");
}
string_view channel = ArgS(args, 0);
string_view messages[] = {ArgS(args, 1)};
@ -2362,10 +2365,16 @@ void Service::Publish(CmdArgList args, ConnectionContext* cntx) {
}
void Service::Subscribe(CmdArgList args, ConnectionContext* cntx) {
if (cluster::IsClusterEnabled()) {
return cntx->SendError("SUBSCRIBE is not supported in cluster mode yet");
}
cntx->ChangeSubscription(true /*add*/, true /* reply*/, std::move(args));
}
void Service::Unsubscribe(CmdArgList args, ConnectionContext* cntx) {
if (cluster::IsClusterEnabled()) {
return cntx->SendError("UNSUBSCRIBE is not supported in cluster mode yet");
}
if (args.size() == 0) {
cntx->UnsubscribeAll(true);
} else {
@ -2374,10 +2383,16 @@ void Service::Unsubscribe(CmdArgList args, ConnectionContext* cntx) {
}
void Service::PSubscribe(CmdArgList args, ConnectionContext* cntx) {
if (cluster::IsClusterEnabled()) {
return cntx->SendError("PSUBSCRIBE is not supported in cluster mode yet");
}
cntx->ChangePSubscription(true, true, args);
}
void Service::PUnsubscribe(CmdArgList args, ConnectionContext* cntx) {
if (cluster::IsClusterEnabled()) {
return cntx->SendError("PUNSUBSCRIBE is not supported in cluster mode yet");
}
if (args.size() == 0) {
cntx->PUnsubscribeAll(true);
} else {
@ -2429,6 +2444,9 @@ void Service::Monitor(CmdArgList args, ConnectionContext* cntx) {
}
void Service::Pubsub(CmdArgList args, ConnectionContext* cntx) {
if (cluster::IsClusterEnabled()) {
return cntx->SendError("PUBSUB is not supported in cluster mode yet");
}
if (args.size() < 1) {
cntx->SendError(WrongNumArgsError(cntx->cid->name()));
return;