[][src]Trait mobc::ConnectionManager

pub trait ConnectionManager: Send + Sync + 'static {
    type Connection: Send + 'static;
    type Error: Error + Send + Sync + 'static;
    type Executor: Executor + Send + Sync + 'static + Clone;
    fn get_executor(&self) -> Self::Executor;
fn connect(&self) -> AnyFuture<Self::Connection, Self::Error>;
fn is_valid(
        &self,
        conn: Self::Connection
    ) -> AnyFuture<Self::Connection, Self::Error>;
fn has_broken(&self, conn: &mut Option<Self::Connection>) -> bool; }

A trait which provides connection-specific functionality.

Associated Types

type Connection: Send + 'static

The connection type this manager deals with.

type Error: Error + Send + Sync + 'static

The error type returned by Connections.

type Executor: Executor + Send + Sync + 'static + Clone

The executor type this manager bases.

Loading content...

Required methods

fn get_executor(&self) -> Self::Executor

Get a future executor.

fn connect(&self) -> AnyFuture<Self::Connection, Self::Error>

Attempts to create a new connection.

fn is_valid(
    &self,
    conn: Self::Connection
) -> AnyFuture<Self::Connection, Self::Error>

Determines if the connection is still connected to the database.

A standard implementation would check if a simple query like SELECT 1 succeeds.

fn has_broken(&self, conn: &mut Option<Self::Connection>) -> bool

Quickly determines if the connection is no longer usable.

This will be called synchronously every time a connection is returned to the pool, so it should not block. If it returns true, the connection will be discarded.

For example, an implementation might check if the underlying TCP socket has disconnected. Implementations that do not support this kind of fast health check may simply return false.

Loading content...

Implementors

Loading content...