[−][src]Trait mongodb::event::cmap::CmapEventHandler
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
fn handle_pool_created_event(&self, event: PoolCreatedEvent)
A Client
will call this method on each registered handler
whenever a connection pool is created.
fn handle_pool_cleared_event(&self, event: PoolClearedEvent)
A Client
will call this method on each registered handler
whenever a connection pool is cleared.
fn handle_pool_closed_event(&self, event: PoolClosedEvent)
A Client
will call this method on each registered handler
whenever a connection pool is cleared.
fn handle_connection_created_event(&self, event: ConnectionCreatedEvent)
A Client
will call this method on each registered handler
whenever a connection is created.
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.
fn handle_connection_closed_event(&self, event: ConnectionClosedEvent)
A Client
will call this method on each registered handler
whenever a connection is closed.
fn handle_connection_checkout_started_event(
&self,
event: ConnectionCheckoutStartedEvent
)
&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.
fn handle_connection_checkout_failed_event(
&self,
event: ConnectionCheckoutFailedEvent
)
&self,
event: ConnectionCheckoutFailedEvent
)
A Client
will call this method on each registered handler
whenever a thread is unable to check out a connection.
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.
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.