lapin icon indicating copy to clipboard operation
lapin copied to clipboard

Automatic reconnection on network failure

Open Keruspe opened this issue 3 years ago • 6 comments

Now that we have the topology API, here are the steps required towards automatic reconnection:

  • [x] add an Option<Consumer> to the wrapped basic_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)

Keruspe avatar Nov 13 '20 20:11 Keruspe

Would you be interested in a PR for this?

robo-corg avatar Mar 17 '21 18:03 robo-corg

Sure. Otherwise I plan to work on this this summer once 2.0 is out

Keruspe avatar Mar 17 '21 18:03 Keruspe

Any update on this?

Automatic reconnects would be really useful for me. I’d even try to contribute if something specific is missing.

kageru avatar Sep 19 '22 12:09 kageru

I'm also interested on this feature

Ks89 avatar Dec 29 '22 14:12 Ks89

I'd be willing to take some sponsorship to work on this

Keruspe avatar Dec 29 '22 14:12 Keruspe

Something like this https://gist.github.com/TroyKomodo/0e746b9dd2b5e4618af2a1b92a6efaf9

TroyKomodo avatar May 02 '23 02:05 TroyKomodo