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
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ยง
Sourcefn handle_pool_created_event(&self, _event: PoolCreatedEvent)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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,
)
๐Deprecated: use the EventHandler API
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,
)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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)
๐Deprecated: use the EventHandler API
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.