Skip to content

Commit

Permalink
renaming pattern, channel, shard-channel
Browse files Browse the repository at this point in the history
Signed-off-by: Sarthak Aggarwal <[email protected]>
  • Loading branch information
sarthakaggarwal97 committed Jan 15, 2025
1 parent 91df97a commit e3fdff0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 64 deletions.
16 changes: 8 additions & 8 deletions src/commands.def
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ commandHistory CLIENT_KILL_History[] = {
{"6.2.0","`LADDR` option."},
{"8.0.0","`MAXAGE` option."},
{"8.0.0","Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."},
{"8.1.0","`ID` option accepts multiple IDs."},
{"8.1.0","`ID` option accepts multiple IDs. Added filters NAME, MINIDLE, FLAGS, SUBSCRIBED-PATTERN, SUBSCRIBED-CHANNEL and SUBSCRIBED-SHARD-CHANNEL"},
};
#endif

Expand Down Expand Up @@ -1331,9 +1331,9 @@ struct COMMAND_ARG CLIENT_KILL_filter_new_format_Subargs[] = {
{MAKE_ARG("name",ARG_TYPE_STRING,-1,"NAME",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("minidle",ARG_TYPE_INTEGER,-1,"MINIDLE",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("flags",ARG_TYPE_STRING,-1,"FLAGS",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("pattern",ARG_TYPE_STRING,-1,"PATTERN",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("channel",ARG_TYPE_STRING,-1,"CHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("shardchannel",ARG_TYPE_STRING,-1,"SHARDCHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("subscribed-pattern",ARG_TYPE_STRING,-1,"SUBSCRIBED-PATTERN",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("subscribed-channel",ARG_TYPE_STRING,-1,"SUBSCRIBED-CHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("subscribed-shard-channel",ARG_TYPE_STRING,-1,"SUBSCRIBED-SHARD-CHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
};

/* CLIENT KILL filter argument table */
Expand All @@ -1359,7 +1359,7 @@ commandHistory CLIENT_LIST_History[] = {
{"7.0.0","Added `resp`, `multi-mem`, `rbs` and `rbp` fields."},
{"7.0.3","Added `ssub` field."},
{"8.0.0","Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."},
{"8.1.0","Added filters USER, ADDR, LADDR, SKIPME, and MAXAGE"},
{"8.1.0","Added filters USER, ADDR, LADDR, SKIPME, MAXAGE, NAME, MINIDLE, FLAGS, SUBSCRIBED-PATTERN, SUBSCRIBED-CHANNEL and SUBSCRIBED-SHARD-CHANNEL."},
};
#endif

Expand Down Expand Up @@ -1401,9 +1401,9 @@ struct COMMAND_ARG CLIENT_LIST_Args[] = {
{MAKE_ARG("name",ARG_TYPE_STRING,-1,"NAME",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("minidle",ARG_TYPE_INTEGER,-1,"MINIDLE",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("flags",ARG_TYPE_STRING,-1,"FLAGS",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("pattern",ARG_TYPE_STRING,-1,"PATTERN",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("channel",ARG_TYPE_STRING,-1,"CHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("shardchannel",ARG_TYPE_STRING,-1,"SHARDCHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("subscribed-pattern",ARG_TYPE_STRING,-1,"SUBSCRIBED-PATTERN",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("subscribed-channel",ARG_TYPE_STRING,-1,"SUBSCRIBED-CHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
{MAKE_ARG("subscribed-shard-channel",ARG_TYPE_STRING,-1,"SUBSCRIBED-SHARD-CHANNEL",NULL,"8.1.0",CMD_ARG_OPTIONAL,0,NULL)},
};

/********** CLIENT NO_EVICT ********************/
Expand Down
14 changes: 7 additions & 7 deletions src/commands/client-kill.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
[
"8.1.0",
"`ID` option accepts multiple IDs. Added filters NAME, MINIDLE, FLAGS, PATTERN, CHANNEL and SHARDCHANNEL."
"`ID` option accepts multiple IDs. Added filters NAME, MINIDLE, FLAGS, SUBSCRIBED-PATTERN, SUBSCRIBED-CHANNEL and SUBSCRIBED-SHARD-CHANNEL"
]
],
"command_flags": [
Expand Down Expand Up @@ -185,22 +185,22 @@
"since": "8.1.0"
},
{
"token": "PATTERN",
"name": "pattern",
"token": "SUBSCRIBED-PATTERN",
"name": "subscribed-pattern",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "CHANNEL",
"name": "channel",
"token": "SUBSCRIBED-CHANNEL",
"name": "subscribed-channel",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "SHARDCHANNEL",
"name": "shardchannel",
"token": "SUBSCRIBED-SHARD-CHANNEL",
"name": "subscribed-shard-channel",
"type": "string",
"optional": true,
"since": "8.1.0"
Expand Down
14 changes: 7 additions & 7 deletions src/commands/client-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
[
"8.1.0",
"Added filters USER, ADDR, LADDR, SKIPME, MAXAGE, NAME, MINIDLE, FLAGS, PATTERN, CHANNEL and SHARDCHANNEL "
"Added filters USER, ADDR, LADDR, SKIPME, MAXAGE, NAME, MINIDLE, FLAGS, SUBSCRIBED-PATTERN, SUBSCRIBED-CHANNEL and SUBSCRIBED-SHARD-CHANNEL."
]
],
"command_flags": [
Expand Down Expand Up @@ -167,22 +167,22 @@
"since": "8.1.0"
},
{
"token": "PATTERN",
"name": "pattern",
"token": "SUBSCRIBED-PATTERN",
"name": "subscribed-pattern",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "CHANNEL",
"name": "channel",
"token": "SUBSCRIBED-CHANNEL",
"name": "subscribed-channel",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "SHARDCHANNEL",
"name": "shardchannel",
"token": "SUBSCRIBED-SHARD-CHANNEL",
"name": "subscribed-shard-channel",
"type": "string",
"optional": true,
"since": "8.1.0"
Expand Down
72 changes: 36 additions & 36 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ typedef struct {
long long min_idle;
/* Client flags for filtering. If NULL, no filtering is applied. */
char *flags;
/* Client pattern for filtering. If NULL, no filtering is applied. */
robj *pattern;
/* Client channel for filtering. If NULL, no filtering is applied. */
robj *channel;
/* Client shard channel for filtering. If NULL, no filtering is applied. */
robj *shard_channel;
/* Client subscribed pattern for filtering. If NULL, no filtering is applied. */
robj *subscribed_pattern;
/* Client subscribed channel for filtering. If NULL, no filtering is applied. */
robj *subscribed_channel;
/* Client subscribed shard channel for filtering. If NULL, no filtering is applied. */
robj *subscribed_shard_channel;
} clientFilter;

static void setProtocolError(const char *errstr, client *c);
Expand Down Expand Up @@ -3623,14 +3623,14 @@ static int parseClientFiltersOrReply(client *c, int index, clientFilter *filter)
} else if (!strcasecmp(c->argv[index]->ptr, "name") && moreargs) {
filter->name = c->argv[index + 1]->ptr;
index += 2;
} else if (!strcasecmp(c->argv[index]->ptr, "pattern") && moreargs) {
filter->pattern = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
} else if (!strcasecmp(c->argv[index]->ptr, "subscribed-pattern") && moreargs) {
filter->subscribed_pattern = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
index += 2;
} else if (!strcasecmp(c->argv[index]->ptr, "channel") && moreargs) {
filter->channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
} else if (!strcasecmp(c->argv[index]->ptr, "subscribed-channel") && moreargs) {
filter->subscribed_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
index += 2;
} else if (!strcasecmp(c->argv[index]->ptr, "shardchannel") && moreargs) {
filter->shard_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
} else if (!strcasecmp(c->argv[index]->ptr, "subscribed-shard-channel") && moreargs) {
filter->subscribed_shard_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
index += 2;
} else {
addReplyErrorObject(c, shared.syntaxerr);
Expand All @@ -3656,9 +3656,9 @@ static int clientMatchesFilter(client *client, clientFilter client_filter) {
return 0;
}
}
if (client_filter.pattern && !clientSubscribedToPattern(client, client_filter.pattern)) return 0;
if (client_filter.channel && !clientSubscribedToChannel(client, client_filter.channel)) return 0;
if (client_filter.shard_channel && !clientSubscribedToShardChannel(client, client_filter.shard_channel)) return 0;
if (client_filter.subscribed_pattern && !clientSubscribedToPattern(client, client_filter.subscribed_pattern)) return 0;
if (client_filter.subscribed_channel && !clientSubscribedToChannel(client, client_filter.subscribed_channel)) return 0;
if (client_filter.subscribed_shard_channel && !clientSubscribedToShardChannel(client, client_filter.subscribed_shard_channel)) return 0;

/* If all conditions are satisfied, the client matches the filter. */
return 1;
Expand Down Expand Up @@ -3806,12 +3806,12 @@ void clientHelpCommand(client *c) {
" Kill connections that include the specified flags.",
" * NAME <client-name>",
" Kill connections with the specified name.",
" * PATTERN <pattern>",
" Kill connections subscribed to a matching pattern.",
" * CHANNEL <channel>",
" Kill connections subscribed to a matching channel.",
" * SHARD-CHANNEL <shard-channel>",
" Kill connections subscribed to a matching shard channel.",
" * SUBSCRIBED-PATTERN <subscribed-pattern>",
" Kill connections subscribed to a matching subscribed pattern.",
" * SUBSCRIBED-CHANNEL <subscribed channel>",
" Kill connections subscribed to a matching subscribed channel.",
" * SUBSCRIBED-SHARD-CHANNEL <subscribed-shard-channel>",
" Kill connections subscribed to a matching subscribe shard channel.",
"LIST [options ...]",
" Return information about client connections. Options:",
" * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)",
Expand All @@ -3834,12 +3834,12 @@ void clientHelpCommand(client *c) {
" Return clients with the specified name.",
" * MIN-IDLE <min-idle>",
" Return clients with idle time greater than or equal to <min-idle> seconds.",
" * PATTERN <pattern>",
" Return clients subscribed to a matching pattern.",
" * CHANNEL <channel>",
" Return clients subscribed to the specified channel.",
" * SHARD-CHANNEL <shard-channel>",
" Return clients subscribed to the specified shard channel.",
" * SUBSCRIBED-PATTERN <subscribed-pattern>",
" Return clients subscribed to a matching subscribed-pattern.",
" * SUBSCRIBED-CHANNEL <subscribed-channel>",
" Return clients subscribed to the specified subscribed-channel.",
" * SUBSCRIBED-SHARD-CHANNEL <shard-subscribed-channel>",
" Return clients subscribed to the specified subscribe shard channel.",
"UNPAUSE",
" Stop the current client pause, resuming traffic.",
"PAUSE <timeout> [WRITE|ALL]",
Expand Down Expand Up @@ -4007,17 +4007,17 @@ void clientKillCommand(client *c) {

static void freeClientFilter(clientFilter *filter) {
zfree(filter->ids);
if (filter->pattern) {
decrRefCount(filter->pattern);
filter->pattern = NULL;
if (filter->subscribed_pattern) {
decrRefCount(filter->subscribed_pattern);
filter->subscribed_pattern = NULL;
}
if (filter->shard_channel) {
decrRefCount(filter->shard_channel);
filter->shard_channel = NULL;
if (filter->subscribed_shard_channel) {
decrRefCount(filter->subscribed_shard_channel);
filter->subscribed_shard_channel = NULL;
}
if (filter->channel) {
decrRefCount(filter->channel);
filter->channel = NULL;
if (filter->subscribed_channel) {
decrRefCount(filter->subscribed_channel);
filter->subscribed_channel = NULL;
}
}

Expand Down
12 changes: 6 additions & 6 deletions tests/unit/introspection.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ start_server {tags {"introspection"}} {
$c1 psubscribe h*llo

# Fetch the client list filtered by channel
set cl [split [r client list pattern h*llo] "\r\n"]
set cl [split [r client list subscribed-pattern h*llo] "\r\n"]

# Assert the client is subscribed to the channel
foreach line $cl {
Expand All @@ -188,7 +188,7 @@ start_server {tags {"introspection"}} {
$c1 subscribe mychannel

# Fetch the client list filtered by channel
set cl [split [r client list channel mychannel] "\r\n"]
set cl [split [r client list subscribed-channel mychannel] "\r\n"]

# Assert the client is subscribed to the channel
foreach line $cl {
Expand All @@ -207,7 +207,7 @@ start_server {tags {"introspection"}} {
$c1 ssubscribe myshardchannel

# Fetch the client list filtered by channel
set cl [split [r client list shardchannel myshardchannel] "\r\n"]
set cl [split [r client list subscribed-shard-channel myshardchannel] "\r\n"]

# Assert the client is subscribed to the channel
foreach line $cl {
Expand Down Expand Up @@ -327,7 +327,7 @@ start_server {tags {"introspection"}} {
$c1 psubscribe h*llo

# Kill the client using the exact name pattern
r client kill pattern h*llo
r client kill subscribed-pattern h*llo

# Assert the client was killed
set err [catch {$c1 ping} error_message]
Expand All @@ -345,7 +345,7 @@ start_server {tags {"introspection"}} {
$c1 subscribe mychannel

# Kill the client using the channel filter
r client kill channel mychannel
r client kill subscribed-channel mychannel

# Assert the client was killed
set err [catch {$c1 ping} error_message]
Expand All @@ -363,7 +363,7 @@ start_server {tags {"introspection"}} {
$c1 ssubscribe myshardchannel

# Kill the client using the shard channel filter
r client kill shardchannel myshardchannel
r client kill subscribed-shard-channel myshardchannel

# Assert the client was killed
set err [catch {$c1 ping} error_message]
Expand Down

0 comments on commit e3fdff0

Please sign in to comment.