Expand description
schmoozer is intended to be used as an async
(re)connector. It
consists of two parts:
- The
Connector
trait is implemented by applications/libraries that need to run retryable connection loops. run()
is a function that takes in aConnector
implementation, and attempts to establish a connection, delaying and retrying on failures that the callback reports as retriable, and calls theConnector::run()
trait method once a connection has been successfully been established.
Perhaps paradoxically the run()
function does not itself actually
attemtp to establish any connections – it relies on the Connector
trait
to implement the means to establish connections.
The “good path” overall flow of the connector loop is to call the
connect()
method. If it is successful, call the run()
method, passing
along the newly allocated connection. The main application logic relating
to the connection should called from this method.
The primary purpose of the connector concerns the “failure path”: If the
connect()
method encounters a failure it can choose to signal to back to
the connector loop that the error is “retryable”, in which case the
retry_delay()
method is called to determine if the connector loop should
retry (and implement a delay before returning instructions to do so).
Likewise, the run()
method returns its Result<(), Self::Error>
wrapped
in a ControlFlow::Continue(_)
to indicate that the connector look should
reconnect, while ControlFlow::Break(_)
signals that a fatal error occured
and the connect loop should terminate.
Re-exports§
pub use tcpconn::SimpleTcpConnector;
Modules§
- tcpconn
tcpconn
A simpleConnector
implementation that specifically attempts to connect to a TCP server and run an async function once successful.
Traits§
- Application callbacks for the
run()
function (or equivalent).
Functions§
- Establish and process a network connection.