RunnerHooks

Trait RunnerHooks 

Source
pub trait RunnerHooks {
    // Provided methods
    fn on_commit_error(
        &self,
        _err: &TransactionCommitError,
    ) -> impl Future<Output = FdbResult<()>> + Send { ... }
    fn on_closure_error(&self, _err: &FdbError) { ... }
    fn on_error_duration(&self, _duration_ms: u64) { ... }
    fn on_commit_success(
        &self,
        _committed: &TransactionCommitted,
        _commit_duration_ms: u64,
    ) { ... }
    fn on_retry(&self) { ... }
    fn on_complete(&self) { ... }
}
Expand description

Lifecycle hooks for the transaction retry runner.

All methods have default no-op implementations, so callers only override what they need. This trait enables a single internal retry loop ([run_with_hooks]) to serve both Database::run() (no-op hooks) and Database::instrumented_run() (metrics hooks).

Provided Methods§

Source

fn on_commit_error( &self, _err: &TransactionCommitError, ) -> impl Future<Output = FdbResult<()>> + Send

Called when commit fails, before on_error() resets the transaction. This is the only window to read conflicting keys or inspect error state.

Errors are logged (behind trace feature) but do not abort the retry loop.

Source

fn on_closure_error(&self, _err: &FdbError)

Called when a closure error triggers a retry.

Source

fn on_error_duration(&self, _duration_ms: u64)

Called after on_error() completes with its duration.

Source

fn on_commit_success( &self, _committed: &TransactionCommitted, _commit_duration_ms: u64, )

Called after successful commit with the committed transaction and commit duration.

Source

fn on_retry(&self)

Called before the next retry iteration (after on_error succeeds).

Source

fn on_complete(&self)

Called when the runner finishes (success or final failure).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§