Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

tishun
Copy link
Collaborator

@tishun tishun commented Mar 6, 2024

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.

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

…s, mostly copied implementation from non-shard NUMSUB command
Copy link
Contributor

@sazzad16 sazzad16 left a 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) {

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?

Copy link
Collaborator Author

@tishun tishun Mar 7, 2024

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?

Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@tishun tishun self-assigned this Mar 7, 2024
Copy link
Contributor

@gerzse gerzse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mp911de mp911de added the type: enhancement A general enhancement label Mar 7, 2024
@mp911de mp911de added this to the 7.x milestone Mar 7, 2024
@@ -251,6 +252,18 @@ void pubsubNumsub() {
assertThat(result).containsKeys(channel);
}

@Test
Copy link
Collaborator

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.

Copy link
Collaborator Author

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);
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, sure, done

@mp911de
Copy link
Collaborator

mp911de commented Mar 7, 2024

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 @since tags to 6.4.

@tishun
Copy link
Collaborator Author

tishun commented Mar 7, 2024

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 @since tags to 6.4.

I think we can wait until we have most of the Shard Channel commands ready to bundle them together

@mp911de
Copy link
Collaborator

mp911de commented Mar 7, 2024

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?

@tishun
Copy link
Collaborator Author

tishun commented Mar 7, 2024

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

@mp911de
Copy link
Collaborator

mp911de commented Mar 8, 2024

Alright, going to proceed with the merge.

@mp911de mp911de linked an issue Mar 8, 2024 that may be closed by this pull request
mp911de pushed a commit that referenced this pull request Mar 8, 2024
mp911de added a commit that referenced this pull request Mar 8, 2024
Reformat code. Add author tags. Fix failing test.
@mp911de
Copy link
Collaborator

mp911de commented Mar 8, 2024

FTR #2756 is about PUBSUB SHARDCHANNELS while this PR handles PUBSUB SHARDNUMSUB therefore the final commits do not refer to #2756.

That's merged, squashed, and polished (626b8a3) now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants