lapin
lapin copied to clipboard
Automatic reconnection on network failure
Now that we have the topology API, here are the steps required towards automatic reconnection:
- [x] add an
Option<Consumer>
to the wrappedbasic_consume
, set it to None from the public wrapper, store the Option in the state and use it to restore everything in the given Consumer if we got Some. - [x] introduce an InternalTopology that stores Connection/Channel/Consumer objects alongside the topology items
- [x] Add some conversion between InternalTopology and Topology; dropping the associated items
- [x] change topology methods to return the Internaltopology, and make the current one use that and convert to public Topology.
- [x] in the same way, introduce some restore_internal, make restore use it, and pass the Options stored in the InternalTopology to basic_consume and friends
- [x] hook up basic get in InternalTopology + restore_internal
- [ ] add an
Option<Channel>
to the channel creation to share internals with the Channel we want to restore, set it to None, but use it when finalizing if it's Some. - [ ] add an
Option<InternalTopology>
set to None to the connection process, and use it when it's some to restore_internal - [ ] detect network failure from the event loop, and instead of bubbling it up, call topology_internal, reinitiate connection with Some(InternalTopology)
Would you be interested in a PR for this?
Sure. Otherwise I plan to work on this this summer once 2.0 is out
Any update on this?
Automatic reconnects would be really useful for me. I’d even try to contribute if something specific is missing.
I'm also interested on this feature
I'd be willing to take some sponsorship to work on this
Something like this https://gist.github.com/TroyKomodo/0e746b9dd2b5e4618af2a1b92a6efaf9