pub trait CommandEventHandler: Send + Sync {
// Provided methods
fn handle_command_started_event(&self, _event: CommandStartedEvent) { ... }
fn handle_command_succeeded_event(&self, _event: CommandSucceededEvent) { ... }
fn handle_command_failed_event(&self, _event: CommandFailedEvent) { ... }
}
๐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 command event sent by the driver.
struct FailedCommandLogger;
impl CommandEventHandler for FailedCommandLogger {
fn handle_command_failed_event(&self, event: CommandFailedEvent) {
eprintln!("Failed command: {:?}", event);
}
}
let handler = Arc::new(FailedCommandLogger);
let options = ClientOptions::builder()
.command_event_handler(handler)
.build();
let client = Client::with_options(options)?;
// Do things with the client, and failed command events will be logged to stderr.
Provided Methodsยง
Sourcefn handle_command_started_event(&self, _event: CommandStartedEvent)
๐Deprecated: use the EventHandler API
fn handle_command_started_event(&self, _event: CommandStartedEvent)
A Client
will call this method on each registered handler
whenever a database command is initiated.
Sourcefn handle_command_succeeded_event(&self, _event: CommandSucceededEvent)
๐Deprecated: use the EventHandler API
fn handle_command_succeeded_event(&self, _event: CommandSucceededEvent)
A Client
will call this method on each registered handler
whenever a database command successfully completes.
Sourcefn handle_command_failed_event(&self, _event: CommandFailedEvent)
๐Deprecated: use the EventHandler API
fn handle_command_failed_event(&self, _event: CommandFailedEvent)
A Client
will call this method on each registered handler
whenever a database command fails to complete successfully.