Skip to content

Commit 89e5c0b

Browse files
renaming pattern, channel, shard-channel
Signed-off-by: Sarthak Aggarwal <[email protected]>
1 parent 91df97a commit 89e5c0b

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

src/networking.c

+36-36
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ typedef struct {
7272
long long min_idle;
7373
/* Client flags for filtering. If NULL, no filtering is applied. */
7474
char *flags;
75-
/* Client pattern for filtering. If NULL, no filtering is applied. */
76-
robj *pattern;
77-
/* Client channel for filtering. If NULL, no filtering is applied. */
78-
robj *channel;
79-
/* Client shard channel for filtering. If NULL, no filtering is applied. */
80-
robj *shard_channel;
75+
/* Client subscribed pattern for filtering. If NULL, no filtering is applied. */
76+
robj *subscribed_pattern;
77+
/* Client subscribed channel for filtering. If NULL, no filtering is applied. */
78+
robj *subscribed_channel;
79+
/* Client subscribed shard channel for filtering. If NULL, no filtering is applied. */
80+
robj *subscribed_shard_channel;
8181
} clientFilter;
8282

8383
static void setProtocolError(const char *errstr, client *c);
@@ -3623,14 +3623,14 @@ static int parseClientFiltersOrReply(client *c, int index, clientFilter *filter)
36233623
} else if (!strcasecmp(c->argv[index]->ptr, "name") && moreargs) {
36243624
filter->name = c->argv[index + 1]->ptr;
36253625
index += 2;
3626-
} else if (!strcasecmp(c->argv[index]->ptr, "pattern") && moreargs) {
3627-
filter->pattern = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
3626+
} else if (!strcasecmp(c->argv[index]->ptr, "subscribed-pattern") && moreargs) {
3627+
filter->subscribed_pattern = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
36283628
index += 2;
3629-
} else if (!strcasecmp(c->argv[index]->ptr, "channel") && moreargs) {
3630-
filter->channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
3629+
} else if (!strcasecmp(c->argv[index]->ptr, "subscribed-channel") && moreargs) {
3630+
filter->subscribed_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
36313631
index += 2;
3632-
} else if (!strcasecmp(c->argv[index]->ptr, "shardchannel") && moreargs) {
3633-
filter->shard_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
3632+
} else if (!strcasecmp(c->argv[index]->ptr, "subscribed-shard-channel") && moreargs) {
3633+
filter->subscribed_shard_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr));
36343634
index += 2;
36353635
} else {
36363636
addReplyErrorObject(c, shared.syntaxerr);
@@ -3656,9 +3656,9 @@ static int clientMatchesFilter(client *client, clientFilter client_filter) {
36563656
return 0;
36573657
}
36583658
}
3659-
if (client_filter.pattern && !clientSubscribedToPattern(client, client_filter.pattern)) return 0;
3660-
if (client_filter.channel && !clientSubscribedToChannel(client, client_filter.channel)) return 0;
3661-
if (client_filter.shard_channel && !clientSubscribedToShardChannel(client, client_filter.shard_channel)) return 0;
3659+
if (client_filter.subscribed_pattern && !clientSubscribedToPattern(client, client_filter.subscribed_pattern)) return 0;
3660+
if (client_filter.subscribed_channel && !clientSubscribedToChannel(client, client_filter.subscribed_channel)) return 0;
3661+
if (client_filter.subscribed_shard_channel && !clientSubscribedToShardChannel(client, client_filter.subscribed_shard_channel)) return 0;
36623662

36633663
/* If all conditions are satisfied, the client matches the filter. */
36643664
return 1;
@@ -3806,12 +3806,12 @@ void clientHelpCommand(client *c) {
38063806
" Kill connections that include the specified flags.",
38073807
" * NAME <client-name>",
38083808
" Kill connections with the specified name.",
3809-
" * PATTERN <pattern>",
3810-
" Kill connections subscribed to a matching pattern.",
3811-
" * CHANNEL <channel>",
3812-
" Kill connections subscribed to a matching channel.",
3813-
" * SHARD-CHANNEL <shard-channel>",
3814-
" Kill connections subscribed to a matching shard channel.",
3809+
" * SUBSCRIBED-PATTERN <subscribed-pattern>",
3810+
" Kill connections subscribed to a matching subscribed pattern.",
3811+
" * SUBSCRIBED-CHANNEL <subscribed channel>",
3812+
" Kill connections subscribed to a matching subscribed channel.",
3813+
" * SUBSCRIBED-SHARD-CHANNEL <subscribed-shard-channel>",
3814+
" Kill connections subscribed to a matching subscribe shard channel.",
38153815
"LIST [options ...]",
38163816
" Return information about client connections. Options:",
38173817
" * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)",
@@ -3834,12 +3834,12 @@ void clientHelpCommand(client *c) {
38343834
" Return clients with the specified name.",
38353835
" * MIN-IDLE <min-idle>",
38363836
" Return clients with idle time greater than or equal to <min-idle> seconds.",
3837-
" * PATTERN <pattern>",
3838-
" Return clients subscribed to a matching pattern.",
3839-
" * CHANNEL <channel>",
3840-
" Return clients subscribed to the specified channel.",
3841-
" * SHARD-CHANNEL <shard-channel>",
3842-
" Return clients subscribed to the specified shard channel.",
3837+
" * SUBSCRIBED-PATTERN <subscribed-pattern>",
3838+
" Return clients subscribed to a matching subscribed-pattern.",
3839+
" * SUBSCRIBED-CHANNEL <subscribed-channel>",
3840+
" Return clients subscribed to the specified subscribed-channel.",
3841+
" * SUBSCRIBED-SHARD-CHANNEL <shard-subscribed-channel>",
3842+
" Return clients subscribed to the specified subscribe shard channel.",
38433843
"UNPAUSE",
38443844
" Stop the current client pause, resuming traffic.",
38453845
"PAUSE <timeout> [WRITE|ALL]",
@@ -4007,17 +4007,17 @@ void clientKillCommand(client *c) {
40074007

40084008
static void freeClientFilter(clientFilter *filter) {
40094009
zfree(filter->ids);
4010-
if (filter->pattern) {
4011-
decrRefCount(filter->pattern);
4012-
filter->pattern = NULL;
4010+
if (filter->subscribed_pattern) {
4011+
decrRefCount(filter->subscribed_pattern);
4012+
filter->subscribed_pattern = NULL;
40134013
}
4014-
if (filter->shard_channel) {
4015-
decrRefCount(filter->shard_channel);
4016-
filter->shard_channel = NULL;
4014+
if (filter->subscribed_shard_channel) {
4015+
decrRefCount(filter->subscribed_shard_channel);
4016+
filter->subscribed_shard_channel = NULL;
40174017
}
4018-
if (filter->channel) {
4019-
decrRefCount(filter->channel);
4020-
filter->channel = NULL;
4018+
if (filter->subscribed_channel) {
4019+
decrRefCount(filter->subscribed_channel);
4020+
filter->subscribed_channel = NULL;
40214021
}
40224022
}
40234023

tests/unit/introspection.tcl

+6-6
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ start_server {tags {"introspection"}} {
169169
$c1 psubscribe h*llo
170170

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

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

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

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

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

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

329329
# Kill the client using the exact name pattern
330-
r client kill pattern h*llo
330+
r client kill subscribed-pattern h*llo
331331

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

347347
# Kill the client using the channel filter
348-
r client kill channel mychannel
348+
r client kill subscribed-channel mychannel
349349

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

365365
# Kill the client using the shard channel filter
366-
r client kill shardchannel myshardchannel
366+
r client kill subscribed-shard-channel myshardchannel
367367

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

0 commit comments

Comments
 (0)