Expand description
schmoozer is intended to be used as an async
(re)connector. It
consists of two primary 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
attempt to establish any connections – it relies on the
Connector::connect()
trait method implementation to establish
connections.
The “good path” overall flow of the connector loop is to call the
connect()
trait method. If it is successful, call the trait’s run()
method, passing along the newly allocated connection. The main application
logic relating to the connection should implemented in this method.
The primary purpose of the connector concerns the “retryable 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 Connector::run()
trait method returns its RunResult
to indicate whether the connector should reconnect or exit, either
successfully or with an error.
§Features
Feature | Function |
---|---|
tcpconn | Enable support for a simple TCP (re)connector. |
tracing | Make the connector loop generator tracing logs. |
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.
Enums§
- Special-purpose result returned by
Connector::connect()
. - Returned by
Connector::run()
Traits§
- Application callbacks for the
run()
function (or equivalent).
Functions§
- Establish and process a network connection.