Rabbit auto uses https://github.com/CleverCloud/lapin.
The library provides a consumer and a publisher, which after the first successful connection run until manually closed. In case of loosing connection to RabbitMQ, they wait until the connection is reestablished without failing.
The current async runtime used is tokio, but it can be easily extended (in the library code) to use different ones.
The version 0.3.0 has a bug which stops automatic reconnection.
There is some deadlock, which I was not able to track, so I have refactored the whole process, and kept most of the interfaces unchanged.
But the configure function has changed, and it is no longer async function.
At the moment the latest version only supports tokio.
Config requires FullExecutor trait and Reactor trait.
Using tokio-reactor-trait and tokio-executor-trait makes this easy.
use ;
use Comms;
use Config;
/// If the configure is not called, the library will kill the app using `std::process::exit()`
/// The configure function is no longer async!
configure;
// Publisher Sink which expects the MsgOut and routing key String
// the created publisher of type impl Sink<(MsgOut, String)> + Unpin,
let publisher = with_dynamic_key.await;
// Publisher Sink which expects the MsgOut
// the created publisher of type impl Sink<MsgOut> + Unpin,
let publisher = with_static_key.await;
// Creates a consumer which returns a Stream of items and auto ack objects.
// The item has to implement Deserialise trait so it is automatically deserialised.
// The auto ack object will automatically acks the delivery when the object drops.
let consumer = StreamBuilder
.create_auto_ack.await;