From 805191c791e1f84618c1f69dacec27ac3fecd1e4 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 31 May 2022 13:55:25 +0800 Subject: [PATCH] rename channel to shardchannel in sharded pubsub commands (#10738) since the sharded pubsub is different with pubsub, it's better to give users a hint to make it more clear. --- src/commands.c | 14 +++++++------- src/commands/pubsub-shardchannels.json | 2 +- src/commands/pubsub-shardnumsub.json | 4 ++-- src/commands/spublish.json | 2 +- src/commands/ssubscribe.json | 2 +- src/commands/sunsubscribe.json | 4 ++-- src/pubsub.c | 12 ++++++------ 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/commands.c b/src/commands.c index 2e694076c..3a46d3f70 100644 --- a/src/commands.c +++ b/src/commands.c @@ -3160,7 +3160,7 @@ struct redisCommandArg PUBSUB_SHARDCHANNELS_Args[] = { /* PUBSUB SHARDNUMSUB argument table */ struct redisCommandArg PUBSUB_SHARDNUMSUB_Args[] = { -{"channel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL|CMD_ARG_MULTIPLE}, +{"shardchannel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL|CMD_ARG_MULTIPLE}, {0} }; @@ -3170,8 +3170,8 @@ struct redisCommand PUBSUB_Subcommands[] = { {"help","Show helpful text about the different subcommands","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_HELP_History,PUBSUB_HELP_tips,pubsubCommand,2,CMD_LOADING|CMD_STALE,0}, {"numpat","Get the count of unique patterns pattern subscriptions","O(1)","2.8.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_NUMPAT_History,PUBSUB_NUMPAT_tips,pubsubCommand,2,CMD_PUBSUB|CMD_LOADING|CMD_STALE,0}, {"numsub","Get the count of subscribers for channels","O(N) for the NUMSUB subcommand, where N is the number of requested channels","2.8.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_NUMSUB_History,PUBSUB_NUMSUB_tips,pubsubCommand,-2,CMD_PUBSUB|CMD_LOADING|CMD_STALE,0,.args=PUBSUB_NUMSUB_Args}, -{"shardchannels","List active shard channels","O(N) where N is the number of active shard channels, and assuming constant time pattern matching (relatively short channels).","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_SHARDCHANNELS_History,PUBSUB_SHARDCHANNELS_tips,pubsubCommand,-2,CMD_PUBSUB|CMD_LOADING|CMD_STALE,0,.args=PUBSUB_SHARDCHANNELS_Args}, -{"shardnumsub","Get the count of subscribers for shard channels","O(N) for the SHARDNUMSUB subcommand, where N is the number of requested channels","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_SHARDNUMSUB_History,PUBSUB_SHARDNUMSUB_tips,pubsubCommand,-2,CMD_PUBSUB|CMD_LOADING|CMD_STALE,0,.args=PUBSUB_SHARDNUMSUB_Args}, +{"shardchannels","List active shard channels","O(N) where N is the number of active shard channels, and assuming constant time pattern matching (relatively short shard channels).","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_SHARDCHANNELS_History,PUBSUB_SHARDCHANNELS_tips,pubsubCommand,-2,CMD_PUBSUB|CMD_LOADING|CMD_STALE,0,.args=PUBSUB_SHARDCHANNELS_Args}, +{"shardnumsub","Get the count of subscribers for shard channels","O(N) for the SHARDNUMSUB subcommand, where N is the number of requested shard channels","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,PUBSUB_SHARDNUMSUB_History,PUBSUB_SHARDNUMSUB_tips,pubsubCommand,-2,CMD_PUBSUB|CMD_LOADING|CMD_STALE,0,.args=PUBSUB_SHARDNUMSUB_Args}, {0} }; @@ -3207,7 +3207,7 @@ struct redisCommandArg PUNSUBSCRIBE_Args[] = { /* SPUBLISH argument table */ struct redisCommandArg SPUBLISH_Args[] = { -{"channel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, +{"shardchannel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, {"message",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, {0} }; @@ -3222,7 +3222,7 @@ struct redisCommandArg SPUBLISH_Args[] = { /* SSUBSCRIBE argument table */ struct redisCommandArg SSUBSCRIBE_Args[] = { -{"channel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_MULTIPLE}, +{"shardchannel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_MULTIPLE}, {0} }; @@ -3250,7 +3250,7 @@ struct redisCommandArg SUBSCRIBE_Args[] = { /* SUNSUBSCRIBE argument table */ struct redisCommandArg SUNSUBSCRIBE_Args[] = { -{"channel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL|CMD_ARG_MULTIPLE}, +{"shardchannel",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_OPTIONAL|CMD_ARG_MULTIPLE}, {0} }; @@ -7274,7 +7274,7 @@ struct redisCommand redisCommandTable[] = { {"spublish","Post a message to a shard channel","O(N) where N is the number of clients subscribed to the receiving shard channel.","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,SPUBLISH_History,SPUBLISH_tips,spublishCommand,3,CMD_PUBSUB|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_MAY_REPLICATE,0,{{NULL,CMD_KEY_NOT_KEY,KSPEC_BS_INDEX,.bs.index={1},KSPEC_FK_RANGE,.fk.range={0,1,0}}},.args=SPUBLISH_Args}, {"ssubscribe","Listen for messages published to the given shard channels","O(N) where N is the number of shard channels to subscribe to.","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,SSUBSCRIBE_History,SSUBSCRIBE_tips,ssubscribeCommand,-2,CMD_PUBSUB|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,{{NULL,CMD_KEY_NOT_KEY,KSPEC_BS_INDEX,.bs.index={1},KSPEC_FK_RANGE,.fk.range={-1,1,0}}},.args=SSUBSCRIBE_Args}, {"subscribe","Listen for messages published to the given channels","O(N) where N is the number of channels to subscribe to.","2.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,SUBSCRIBE_History,SUBSCRIBE_tips,subscribeCommand,-2,CMD_PUBSUB|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,.args=SUBSCRIBE_Args}, -{"sunsubscribe","Stop listening for messages posted to the given shard channels","O(N) where N is the number of clients already subscribed to a channel.","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,SUNSUBSCRIBE_History,SUNSUBSCRIBE_tips,sunsubscribeCommand,-1,CMD_PUBSUB|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,{{NULL,CMD_KEY_NOT_KEY,KSPEC_BS_INDEX,.bs.index={1},KSPEC_FK_RANGE,.fk.range={-1,1,0}}},.args=SUNSUBSCRIBE_Args}, +{"sunsubscribe","Stop listening for messages posted to the given shard channels","O(N) where N is the number of clients already subscribed to a shard channel.","7.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,SUNSUBSCRIBE_History,SUNSUBSCRIBE_tips,sunsubscribeCommand,-1,CMD_PUBSUB|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE,0,{{NULL,CMD_KEY_NOT_KEY,KSPEC_BS_INDEX,.bs.index={1},KSPEC_FK_RANGE,.fk.range={-1,1,0}}},.args=SUNSUBSCRIBE_Args}, {"unsubscribe","Stop listening for messages posted to the given channels","O(N) where N is the number of clients already subscribed to a channel.","2.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_PUBSUB,UNSUBSCRIBE_History,UNSUBSCRIBE_tips,unsubscribeCommand,-1,CMD_PUBSUB|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SENTINEL,0,.args=UNSUBSCRIBE_Args}, /* scripting */ {"eval","Execute a Lua script server side","Depends on the script that is executed.","2.6.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_SCRIPTING,EVAL_History,EVAL_tips,evalCommand,-3,CMD_NOSCRIPT|CMD_SKIP_MONITOR|CMD_MAY_REPLICATE|CMD_NO_MANDATORY_KEYS|CMD_STALE,ACL_CATEGORY_SCRIPTING,{{"We cannot tell how the keys will be used so we assume the worst, RW and UPDATE",CMD_KEY_RW|CMD_KEY_ACCESS|CMD_KEY_UPDATE,KSPEC_BS_INDEX,.bs.index={2},KSPEC_FK_KEYNUM,.fk.keynum={0,1,1}}},evalGetKeys,.args=EVAL_Args}, diff --git a/src/commands/pubsub-shardchannels.json b/src/commands/pubsub-shardchannels.json index 3bffa221f..90b907d30 100644 --- a/src/commands/pubsub-shardchannels.json +++ b/src/commands/pubsub-shardchannels.json @@ -1,7 +1,7 @@ { "SHARDCHANNELS": { "summary": "List active shard channels", - "complexity": "O(N) where N is the number of active shard channels, and assuming constant time pattern matching (relatively short channels).", + "complexity": "O(N) where N is the number of active shard channels, and assuming constant time pattern matching (relatively short shard channels).", "group": "pubsub", "since": "7.0.0", "arity": -2, diff --git a/src/commands/pubsub-shardnumsub.json b/src/commands/pubsub-shardnumsub.json index 8c51549b0..89187696a 100644 --- a/src/commands/pubsub-shardnumsub.json +++ b/src/commands/pubsub-shardnumsub.json @@ -1,7 +1,7 @@ { "SHARDNUMSUB": { "summary": "Get the count of subscribers for shard channels", - "complexity": "O(N) for the SHARDNUMSUB subcommand, where N is the number of requested channels", + "complexity": "O(N) for the SHARDNUMSUB subcommand, where N is the number of requested shard channels", "group": "pubsub", "since": "7.0.0", "arity": -2, @@ -14,7 +14,7 @@ ], "arguments": [ { - "name": "channel", + "name": "shardchannel", "type": "string", "optional": true, "multiple": true diff --git a/src/commands/spublish.json b/src/commands/spublish.json index 816ff0ad3..6ed748f95 100644 --- a/src/commands/spublish.json +++ b/src/commands/spublish.json @@ -15,7 +15,7 @@ ], "arguments": [ { - "name": "channel", + "name": "shardchannel", "type": "string" }, { diff --git a/src/commands/ssubscribe.json b/src/commands/ssubscribe.json index c49f801a6..a63d520f1 100644 --- a/src/commands/ssubscribe.json +++ b/src/commands/ssubscribe.json @@ -14,7 +14,7 @@ ], "arguments": [ { - "name": "channel", + "name": "shardchannel", "type": "string", "multiple": true } diff --git a/src/commands/sunsubscribe.json b/src/commands/sunsubscribe.json index 5b428237b..df9ae9cac 100644 --- a/src/commands/sunsubscribe.json +++ b/src/commands/sunsubscribe.json @@ -1,7 +1,7 @@ { "SUNSUBSCRIBE": { "summary": "Stop listening for messages posted to the given shard channels", - "complexity": "O(N) where N is the number of clients already subscribed to a channel.", + "complexity": "O(N) where N is the number of clients already subscribed to a shard channel.", "group": "pubsub", "since": "7.0.0", "arity": -1, @@ -14,7 +14,7 @@ ], "arguments": [ { - "name": "channel", + "name": "shardchannel", "type": "string", "optional": true, "multiple": true diff --git a/src/pubsub.c b/src/pubsub.c index da1bd1fc2..2b063455d 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -607,10 +607,10 @@ void pubsubCommand(client *c) { " Return number of subscriptions to patterns.", "NUMSUB [ ...]", " Return the number of subscribers for the specified channels, excluding", -" pattern subscriptions(default: no channels)." +" pattern subscriptions(default: no channels).", "SHARDCHANNELS []", " Return the currently active shard level channels matching a (default: '*').", -"SHARDNUMSUB [ ...]", +"SHARDNUMSUB [ ...]", " Return the number of subscribers for the specified shard level channel(s)", NULL }; @@ -642,7 +642,7 @@ NULL sds pat = (c->argc == 2) ? NULL : c->argv[2]->ptr; channelList(c,pat,server.pubsubshard_channels); } else if (!strcasecmp(c->argv[1]->ptr,"shardnumsub") && c->argc >= 2) { - /* PUBSUB SHARDNUMSUB [Channel_1 ... Channel_N] */ + /* PUBSUB SHARDNUMSUB [ShardChannel_1 ... ShardChannel_N] */ int j; addReplyArrayLen(c, (c->argc-2)*2); @@ -679,7 +679,7 @@ void channelList(client *c, sds pat, dict *pubsub_channels) { setDeferredArrayLen(c,replylen,mblen); } -/* SPUBLISH */ +/* SPUBLISH */ void spublishCommand(client *c) { int receivers = pubsubPublishMessageAndPropagateToCluster(c->argv[1],c->argv[2],1); if (!server.cluster_enabled) @@ -687,7 +687,7 @@ void spublishCommand(client *c) { addReplyLongLong(c,receivers); } -/* SSUBSCRIBE channel [channel ...] */ +/* SSUBSCRIBE shardchannel [shardchannel ...] */ void ssubscribeCommand(client *c) { if (c->flags & CLIENT_DENY_BLOCKING) { /* A client that has CLIENT_DENY_BLOCKING flag on @@ -711,7 +711,7 @@ void ssubscribeCommand(client *c) { } -/* SUNSUBSCRIBE [channel [channel ...]] */ +/* SUNSUBSCRIBE [shardchannel [shardchannel ...]] */ void sunsubscribeCommand(client *c) { if (c->argc == 1) { pubsubUnsubscribeShardAllChannels(c, 1);