-
Notifications
You must be signed in to change notification settings - Fork 178
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
docs: ability to declare queue/exchange binding #2011
Conversation
Sorry, but I don't think, that the new method required async def declare_binding(
self,
queue: "RabbitQueue",
exchange: "RabbitExchange",
routing_key: Optional[str] = None,
) -> None:
"""Declare a binding between a queue and an exchange."""
q = await self.declare_queue(queue)
exch = await self.declare_exchange(exchange)
await q.bind(
exchange=exch,
routing_key=routing_key,
) Inner code looks simple enough to provide it to user as it. Probably, we can just add such example to the documentation? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, we can just add the example to the doc as it
You're right, now that I think about it it's just syntactic sugar. I reverted changes and added the example to the doc |
@MagicAbdel thank you for the suggestion and the PR itself! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using includable python files to be sure, that all code examples are runnable and correct. This reason we have a special tests for such files in tests/docs/...
It will be kind, if you add any test for you code example. I think, it should use monkeypathcing to check, that inner aio-pika method was called correctly
That was my bad I didn't notice there were tests for doc code snippets, that is really nice btw! I just added relevant test |
Finall, I just want to clone the repo and take a look at compiled documentation. Then I'll merge it. Thank your for the work! |
* feat: declare queue/exchange binding * docs: generate API References * docs: reverting the changes and adding queue/exchange binding to the documentation * docs: reverting the changes and adding queue/exchange binding to the documentation * docs: reverting the changes and adding queue/exchange binding to the documentation * docs: generate API References * test: added some testing for the doc code snippet * chore: polish docs * tests: fix RMQ bind test --------- Co-authored-by: MagicAbdel <[email protected]> Co-authored-by: Nikita Pastukhov <[email protected]>
Description
Hi,
I was implementing dead lettering in RabbitMQ using faststream and I had to bind an queue/exchange. It resulted in the following:
With this; It can now can be written in a single line as (without accessing the "private"
_channel
):Included a unit test scenario where we declare a queue/exchange binding, making sure that single call is made to the declare_queue/declare_exchange.
There might be some improvements to this code but I believe they should be in the RabbitQueue and not in the declarer. Let me know if there is anything to change.
NOTE: while running
scripts/test-cov.sh
I got the following (As I didn't touch any of these I just skipped it):FAILED tests/prometheus/confluent/test_confluent.py::TestConsume::test_concurrent_consume - assert False FAILED tests/a_docs/nats/js/test_object.py::test_basic - AssertionError: Expected 'mock' to be called once. Called 2 times.
Fixes #NOT_APPLICABLE
Type of change
Please delete options that are not relevant.
Checklist
scripts/lint.sh
shows no errors)scripts/test-cov.sh
scripts/static-analysis.sh