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

Feature: support path-based arguments #764

Closed
Lancetnik opened this issue Sep 27, 2023 · 2 comments · Fixed by #823
Closed

Feature: support path-based arguments #764

Lancetnik opened this issue Sep 27, 2023 · 2 comments · Fixed by #823
Labels
enhancement New feature or request

Comments

@Lancetnik
Copy link
Member

Lancetnik commented Sep 27, 2023

Some brokers (RMQ, NATS, Redis, etc) allows you to consume messages by pattern
So, we can support path-based arguments in this case

from faststream import FastStream, Path
from faststream.nats import NatsBroker

broker = NatsBroker()
app = FastStream(broker)

@broker.subscriber("subject.{user_id}")
async def handler(msg, user_id: str = Path()):
    ...
@Lancetnik Lancetnik added the enhancement New feature or request label Sep 27, 2023
@Lancetnik Lancetnik moved this to Backlog in FastStream Sep 27, 2023
@snorfalorpagus
Copy link

I can see this being a useful feature.

How would the different pattern matching syntaxes for RMQ/NATS/Redis/etc be handled? For example, RMQ supports either * (one word) or # (none or more words) as wildcards, while Redis uses glob-style patterns like * (none or more characters) and h[ae]llo. Would this just have to make an assumption (e.g. subject.{user_id} translates to subject.* in RMQ and subject.* in Redis)?

@Lancetnik
Copy link
Member Author

Lancetnik commented Sep 28, 2023

It was just a little thought to add in backlog, without any details.
Sure, you are right {user_id} just a pattern for '.*' RMQ and '.\w' Redis case
There are no any problem to support different features for different brokers via ABCParser inheritors, so I have a plan to create unified syntax, but not all of its' features will be supported at all brokers cases

@Lancetnik Lancetnik mentioned this issue Oct 12, 2023
13 tasks
github-merge-queue bot pushed a commit that referenced this issue Oct 15, 2023
* feat (#764): Context dict keys, Path and Header objects

* feat: check only exchange name at publish

* feat: fast access to Message annotations

* test: fix empty handler case

* chore: refactor Test CI

* chore: add distribution tests

* chore: fix distribution tests

* chore: fix real broker tests

* lint: fix mypy

* chore: fix coverage CI

* docs (#682): fill publisher pages, add header, path sections

* chore: fix CI merging

* Add untracked files

* Proofread docs and fix issues

---------

Co-authored-by: Kumaran Rajendhiran <[email protected]>
@github-project-automation github-project-automation bot moved this from Backlog to Done in FastStream Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants