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

fix: add group/consumer to hash to avoid overwriting #1463

Merged
merged 3 commits into from
May 24, 2024

Conversation

fbraem
Copy link
Contributor

@fbraem fbraem commented May 23, 2024

Description

This allows subscribers to use the same Redis stream:

  • with the same group, but with multiple consumers to load balance the messages between several subscribers.
@broker.subscriber(stream="test-stream", group="test-group-1", consumer="test-consumer-1")
async def handle_1(msg: str):
    print(msg)

@broker.subscriber(stream="test-stream", group="test-group-1", consumer="test-consumer-2")
async def handle_2(msg: str):
    print(msg)
  • with multiple groups to allow a message to be handled by multiple subscribers (pub/sub)
@broker.subscriber(stream="test-stream", group="test-group-1", consumer="test-consumer-1")
async def sub_1(msg: str):
    print(msg)

@broker.subscriber(stream="test-stream", group="test-group-2", consumer="test-consumer-2")
async def sub_2(msg: str):
    print(msg)

Without this fix, the subscribers are overwritten because the group and consumer are not part of the hash.

Type of change

Please delete options that are not relevant.

  • Documentation (typos, code examples, or any documentation updates)
  • Bug fix (a non-breaking change that resolves an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a fix or feature that would disrupt existing functionality)
  • This change requires a documentation update

Checklist

  • My code adheres to the style guidelines of this project (scripts/lint.sh shows no errors)
  • I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation
  • My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix or the functionality of my new feature
  • Both new and existing unit tests pass successfully on my local environment by running scripts/test-cov.sh
  • I have ensured that static analysis tests are passing by running scripts/static-analysis.sh
  • I have included code examples to illustrate the modifications

@Lancetnik
Copy link
Member

Thank you for the PR! I'll merge it as soon as I can dig into why CI broken

@Lancetnik Lancetnik added this pull request to the merge queue May 24, 2024
@Lancetnik Lancetnik removed this pull request from the merge queue due to a manual request May 24, 2024
@kumaranvpl kumaranvpl enabled auto-merge May 24, 2024 09:51
@kumaranvpl kumaranvpl added this pull request to the merge queue May 24, 2024
Merged via the queue into airtai:main with commit f3bc25c May 24, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants