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

feat: nats filter JS subscription support #1519

Merged
merged 3 commits into from
Jun 12, 2024
Merged

Conversation

Lancetnik
Copy link
Collaborator

Description

Now FastStream has native interface for NATS JetStream subscription

from faststream import FastStream, Logger
from faststream.nats import ConsumerConfig, JStream, NatsBroker

broker = NatsBroker()
app = FastStream(broker)

@broker.subscriber(
    config=ConsumerConfig(
        filter_subjects=["b.a", "b.b"],
    ),
    stream=JStream(
        "test-stream2",
        subjects=["b.*"],
    ),
)
async def handler(msg, logger: Logger):
    logger.info(msg)

@app.after_startup
async def test():
    await broker.publish(1, "b.a")
    await broker.publish(2, "b.b")
    await broker.publish(3, "b.c")  # will not be handled

Please include a summary of the change and specify which issue is being addressed. Additionally, provide relevant motivation and context.

Fixes #1518

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 Lancetnik added enhancement New feature or request NATS Issues related to `faststream.nats` module and NATS broker features labels Jun 11, 2024
@kumaranvpl kumaranvpl added this pull request to the merge queue Jun 12, 2024
Merged via the queue into main with commit f7a5c19 Jun 12, 2024
30 checks passed
@kumaranvpl kumaranvpl deleted the feat/nats-filter-support branch June 12, 2024 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request NATS Issues related to `faststream.nats` module and NATS broker features
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Feature: support NATS filter subscription
2 participants