Trait ManageConnection

Source
pub trait ManageConnection:
    Send
    + Sync
    + 'static {
    type Connection: Send + 'static;

    // Required methods
    fn connect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Connection>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn check<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn: &'life1 mut Self::Connection,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait which provides connection-specific functionality.

Required Associated Types§

Source

type Connection: Send + 'static

The connection type this manager deals with.

Required Methods§

Source

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Connection>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to create a new connection.

Source

fn check<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 mut Self::Connection, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if the connection is still valid, check background every check_interval.

A standard implementation would check if a simple query like PING succee, if the Connection is broken, error should return.

Implementors§