-
Notifications
You must be signed in to change notification settings - Fork 202
add robust_connection_multihost.py #680
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
base: master
Are you sure you want to change the base?
add robust_connection_multihost.py #680
Conversation
|
Going to add some tests |
|
Fixes #141 |
| super().__init__(str(self.urls[0]), **kwargs) | ||
|
|
||
| def _prepare_url(self, url: str, default_port: int) -> URL: | ||
| if not url.startswith("amqp://"): |
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.
what about amqps?
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 should consider that! right, thanks
| from aio_pika.robust_connection import RobustConnection | ||
| import asyncio | ||
|
|
||
| class RobustConnectionMultiHost(RobustConnection): |
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.
RobustConnectionRRHost semantically it is closer, because you connection is not a multihost, it is a round-robin retying to connect only to one.
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.
right, thanks. I'm going to review the module and add some tests
| await super()._on_connection_close(closing) | ||
|
|
||
| async def reconnect(self): | ||
| await asyncio.sleep(2) |
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.
Why 2? Why not 60 or 0.0001?
db67837 to
fee1abe
Compare
Add RobustConnectionMultiHost class for fault-tolerant RabbitMQ connections:
Implements a connection class that tries multiple broker URLs in sequence until one succeeds.
Automatically handles reconnection on unexpected connection closures.