CmapEventHandler

Trait CmapEventHandler 

Source
pub trait CmapEventHandler: Send + Sync {
    // Provided methods
    fn handle_pool_created_event(&self, _event: PoolCreatedEvent) { ... }
    fn handle_pool_ready_event(&self, _event: PoolReadyEvent) { ... }
    fn handle_pool_cleared_event(&self, _event: PoolClearedEvent) { ... }
    fn handle_pool_closed_event(&self, _event: PoolClosedEvent) { ... }
    fn handle_connection_created_event(&self, _event: ConnectionCreatedEvent) { ... }
    fn handle_connection_ready_event(&self, _event: ConnectionReadyEvent) { ... }
    fn handle_connection_closed_event(&self, _event: ConnectionClosedEvent) { ... }
    fn handle_connection_checkout_started_event(
        &self,
        _event: ConnectionCheckoutStartedEvent,
    ) { ... }
    fn handle_connection_checkout_failed_event(
        &self,
        _event: ConnectionCheckoutFailedEvent,
    ) { ... }
    fn handle_connection_checked_out_event(
        &self,
        _event: ConnectionCheckedOutEvent,
    ) { ... }
    fn handle_connection_checked_in_event(
        &self,
        _event: ConnectionCheckedInEvent,
    ) { ... }
}
๐Ÿ‘ŽDeprecated: use the EventHandler API
Expand description

Usage of this trait is deprecated. Applications should use the EventHandler API.

Applications can implement this trait to specify custom logic to run on each CMAP event sent by the driver.

struct FailedCheckoutLogger;

impl CmapEventHandler for FailedCheckoutLogger {
    fn handle_connection_checkout_failed_event(&self, event: ConnectionCheckoutFailedEvent) {
        eprintln!("Failed connection checkout: {:?}", event);
    }
}

let handler = Arc::new(FailedCheckoutLogger);
let options = ClientOptions::builder()
                  .cmap_event_handler(handler)
                  .build();
let client = Client::with_options(options)?;

// Do things with the client, and failed connection pool checkouts will be logged to stderr.

Provided Methodsยง

Source

fn handle_pool_created_event(&self, _event: PoolCreatedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection pool is created.

Source

fn handle_pool_ready_event(&self, _event: PoolReadyEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection pool marked as ready for use.

Connections may not be created by or checked out from the pool until it has been marked as ready.

Source

fn handle_pool_cleared_event(&self, _event: PoolClearedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection pool is cleared.

Source

fn handle_pool_closed_event(&self, _event: PoolClosedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection pool is cleared.

Source

fn handle_connection_created_event(&self, _event: ConnectionCreatedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection is created.

Source

fn handle_connection_ready_event(&self, _event: ConnectionReadyEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection is ready to be used.

Source

fn handle_connection_closed_event(&self, _event: ConnectionClosedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection is closed.

Source

fn handle_connection_checkout_started_event( &self, _event: ConnectionCheckoutStartedEvent, )

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a thread begins checking out a connection to use for an operation.

Source

fn handle_connection_checkout_failed_event( &self, _event: ConnectionCheckoutFailedEvent, )

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a thread is unable to check out a connection.

Source

fn handle_connection_checked_out_event(&self, _event: ConnectionCheckedOutEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection is successfully checked out.

Source

fn handle_connection_checked_in_event(&self, _event: ConnectionCheckedInEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a connection is checked back into a connection pool.

Implementorsยง