Skip to content

Add support for PUBSUB SHARDNUMSUB #2541

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

Merged
merged 5 commits into from
Sep 19, 2023
Merged

Conversation

david02324
Copy link
Contributor

@david02324 david02324 commented Jun 19, 2023

Description

Describe your pull request here

very similar to the existing implementation of the PUBSUB NUMSUB command. :)


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

export function transformReply(rawReply: Array<string | number>): Record<string, number> {
const transformedReply = Object.create(null);

for (let i = 0; i < rawReply.length; i +=2) {
Copy link

@younes-io younes-io Jun 23, 2023

Choose a reason for hiding this comment

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

You can use entries() to iterate over the array of records.. something idiomatic like:

 for (const [channel, numSubscribers] of rawReply.entries()) {
    transformedReply[channel] = numSubscribers;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every first factor of the iterator returned by the entries() is index, so I think it is not an appropriate use 🤔

Choose a reason for hiding this comment

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

How does "rawReply" look like ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://redis.io/commands/pubsub-shardnumsub/

Same as reply in pubsub numsub. Repeated channel(string) and count(number)

Copy link
Contributor

@leibale leibale left a comment

Choose a reason for hiding this comment

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

overall looks good, the tests need some changes..

Thanks for contributing! :)

});

testUtils.testWithClient('client.pubSubShardNumSub', async client => {
assert.deepEqual(
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please make the test "non empty" so it'll actually test transforReply as well?

@david02324 david02324 requested a review from leibale July 4, 2023 04:41
@leibale leibale changed the title Add support for PUBSUB SHARDNUMSUB command Add support for PUBSUB SHARDNUMSUB Sep 18, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2023

Codecov Report

Patch coverage: 96.77% and project coverage change: +0.02% 🎉

Comparison is base (a7d5bc7) 95.70% compared to head (8a84878) 95.72%.
Report is 20 commits behind head on master.

❗ Current head 8a84878 differs from pull request most recent head 1618630. Consider uploading reports for the commit 1618630 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2541      +/-   ##
==========================================
+ Coverage   95.70%   95.72%   +0.02%     
==========================================
  Files         456      459       +3     
  Lines        4561     4543      -18     
  Branches      524      507      -17     
==========================================
- Hits         4365     4349      -16     
  Misses        127      127              
+ Partials       69       67       -2     
Files Changed Coverage Δ
packages/search/lib/commands/SEARCH.ts 82.60% <ø> (ø)
packages/client/lib/client/index.ts 92.74% <75.00%> (-0.84%) ⬇️
packages/client/lib/client/commands.ts 100.00% <100.00%> (ø)
packages/client/lib/commands/CLIENT_NO-TOUCH.ts 100.00% <100.00%> (ø)
packages/client/lib/commands/PUBSUB_SHARDNUMSUB.ts 100.00% <100.00%> (ø)
packages/json/lib/commands/MERGE.ts 100.00% <100.00%> (ø)
packages/search/lib/commands/SEARCH_NOCONTENT.ts 100.00% <100.00%> (ø)

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leibale leibale merged commit 6848f3d into redis:master Sep 19, 2023
@leibale
Copy link
Contributor

leibale commented Sep 19, 2023

@david02324 @younes-io [email protected]/@redis/[email protected] is on npm 🎉

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

Successfully merging this pull request may close these issues.

4 participants