[][src]Trait cueball::connection::Connection

pub trait Connection: Send + Sized + 'static {
    type Error: Error;
    fn connect(&mut self) -> Result<(), Self::Error>;
fn close(&mut self) -> Result<(), Self::Error>; fn is_valid(&mut self) -> bool { ... }
fn has_broken(&self) -> bool { ... } }

Cueball connection

The Connection trait defines the interface that must be implemented in order to participate in a Cueball connection pool. A connection need not be limited to a TCP socket, but could be any logical notion of a connection that implements the Connection trait.

Associated Types

type Error: Error

The error type returned by the connect or close functions. This is an associated type for the trait meaning each specific implementation of the Connection trait may choose the appropriate concrete error type to return. The only constraint applied is that the selected error type must implement the Error trait from the standard library. This allows for the error to relevant to the context of the Connection implementation while avoiding unnecessary type parameters or having to coerce data between incompatible error types.

Loading content...

Required methods

fn connect(&mut self) -> Result<(), Self::Error>

Attempt to establish the connection to a backend. Connection trait implementors are provided with details about the backend when the create_connection function is invoked by the connection pool upon notification by the Resolver that a new backend is available. The create_connection function is provided to the connection pool via the input parameters to ConnectionPool::new. Returns an error if the connection attempt fails.

fn close(&mut self) -> Result<(), Self::Error>

Close the connection to the backend

Loading content...

Provided methods

fn is_valid(&mut self) -> bool

check the to see if connection is still up and working. The connection pool runs this function as the connection is being replaced and triggers a rebalance if the connection is unhealthy.

fn has_broken(&self) -> bool

Loading content...

Implementors

Loading content...