CommandEventHandler

Trait CommandEventHandler 

Source
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ยง

Source

fn handle_command_started_event(&self, _event: CommandStartedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a database command is initiated.

Source

fn handle_command_succeeded_event(&self, _event: CommandSucceededEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a database command successfully completes.

Source

fn handle_command_failed_event(&self, _event: CommandFailedEvent)

๐Ÿ‘ŽDeprecated: use the EventHandler API

A Client will call this method on each registered handler whenever a database command fails to complete successfully.

Implementorsยง