-
Notifications
You must be signed in to change notification settings - Fork 945
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
Implement the PUBSUB SHARDNUMSUB command #2776
Conversation
…s, mostly copied implementation from non-shard NUMSUB command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea/Approach LGTM!
@@ -2107,6 +2107,14 @@ Command<K, V, Map<K, Long>> pubsubNumsub(K... pattern) { | |||
return createCommand(PUBSUB, (MapOutput) new MapOutput<K, Long>((RedisCodec) codec), args); | |||
} | |||
|
|||
Command<K, V, Map<K, Long>> pubsubShardNumsub(K... pattern) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there's the reason why in this signature argument called pattern
and not channels
as in other places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly consistency with the other method in the class that handles a similar role
Command<K, V, Map<K, Long>> pubsubNumsub(K... pattern) {
That being said we might want to change the argument name in both.
@mp911de what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have to clean up things, then let's rename the arguments of NUMSUB
to channel
. How about changing pubsubShardNumsub(K... pattern)
to pubsubShardNumsub(K... shardchannel)
to align with the Redis command documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally, let me address that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -251,6 +252,18 @@ void pubsubNumsub() { | |||
assertThat(result).containsKeys(channel); | |||
} | |||
|
|||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's guard the test with @EnabledOnCommand("SPUBLISH")
to ensure that the test only runs when Redis has the shared pub/sub functionality. We typically keep the tests guarded to run tests against lower Redis versions if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, will do
* @param channels channel keys. | ||
* @return array-reply a list of channels and number of subscribers for every channel. | ||
*/ | ||
Map<K, Long> pubsubShardNumsub(K... channels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Add @since 7.0
and propagate that change into the generated commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sure, done
Left a few remarks. I think, the next Lettuce version is going to be 7.0. If we decide, that we want to publish a 6.4 instead, we can then switch all |
I think we can wait until we have most of the Shard Channel commands ready to bundle them together |
…ce when is the command available
This looks pretty decent. Do you want to add the remainder of Pub/Sub sharding commands or should we merge a PR for each command? |
Thanks! We discussed this with @chayim and we think it would be cleaner to have separate pull requests per command and when we're done with them we can merge them all together. It gives us the flexibility to both have smaller / simpler reviews and also decide when to add them according to the situation |
Alright, going to proceed with the merge. |
This is a proposed solution to #2756
Used the template engine to add the command to all required interfaces
Mostly copied implementation from PUBSUB NUMSUB command as they share a common interface
Since there is no implementation for SSUBSCRIBE the tests are currently only testing the negative scenario.
Positive verifications were made by executing the SSUBSCRIBE manually with the CLI and running the new command in the Demo class.