Trait mongodb::event::cmap::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
    ) { ... }
}Expand description
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<dyn CmapEventHandler> = 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§
sourcefn handle_pool_created_event(&self, _event: PoolCreatedEvent)
 
fn handle_pool_created_event(&self, _event: PoolCreatedEvent)
A Client will call this method on each registered handler
whenever a connection pool is created.
sourcefn handle_pool_ready_event(&self, _event: PoolReadyEvent)
 
fn handle_pool_ready_event(&self, _event: PoolReadyEvent)
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.
sourcefn handle_pool_cleared_event(&self, _event: PoolClearedEvent)
 
fn handle_pool_cleared_event(&self, _event: PoolClearedEvent)
A Client will call this method on each registered handler
whenever a connection pool is cleared.
sourcefn handle_pool_closed_event(&self, _event: PoolClosedEvent)
 
fn handle_pool_closed_event(&self, _event: PoolClosedEvent)
A Client will call this method on each registered handler
whenever a connection pool is cleared.
sourcefn handle_connection_created_event(&self, _event: ConnectionCreatedEvent)
 
fn handle_connection_created_event(&self, _event: ConnectionCreatedEvent)
A Client will call this method on each registered handler
whenever a connection is created.
sourcefn handle_connection_ready_event(&self, _event: ConnectionReadyEvent)
 
fn handle_connection_ready_event(&self, _event: ConnectionReadyEvent)
A Client will call this method on each registered handler
whenever a connection is ready to be used.
sourcefn handle_connection_closed_event(&self, _event: ConnectionClosedEvent)
 
fn handle_connection_closed_event(&self, _event: ConnectionClosedEvent)
A Client will call this method on each registered handler
whenever a connection is closed.
sourcefn handle_connection_checkout_started_event(
    &self,
    _event: ConnectionCheckoutStartedEvent
)
 
fn handle_connection_checkout_started_event( &self, _event: ConnectionCheckoutStartedEvent )
A Client will call this method on each registered handler
whenever a thread begins checking out a connection to use for an operation.
sourcefn handle_connection_checkout_failed_event(
    &self,
    _event: ConnectionCheckoutFailedEvent
)
 
fn handle_connection_checkout_failed_event( &self, _event: ConnectionCheckoutFailedEvent )
A Client will call this method on each registered handler
whenever a thread is unable to check out a connection.
sourcefn handle_connection_checked_out_event(&self, _event: ConnectionCheckedOutEvent)
 
fn handle_connection_checked_out_event(&self, _event: ConnectionCheckedOutEvent)
A Client will call this method on each registered handler
whenever a connection is successfully checked out.
sourcefn handle_connection_checked_in_event(&self, _event: ConnectionCheckedInEvent)
 
fn handle_connection_checked_in_event(&self, _event: ConnectionCheckedInEvent)
A Client will call this method on each registered handler
whenever a connection is checked back into a connection pool.