Expand description
The retry runner behind Database::run.
The runner is built from three independent pieces:
- the attempt: run the closure on a transaction, then commit it. One attempt does exactly one pass and never retries.
- the hooks (
RunnerHooks): purely observational callbacks fired around each attempt. They cannot change what the runner decides. - the policy (
RetryPolicy): the only thing that can change a decision. It sees the failure and the decision the runner proposes, and returns the decision to apply.
They are assembled by TransactionRunner, the builder returned by
Database::runner:
let metrics = TransactionMetrics::new();
db.runner()
.hooks(&MetricsHooks::new(&metrics))
.run(|trx, _maybe_committed| async move {
trx.set(b"key", b"value");
Ok::<_, FdbBindingError>(())
})
.await?;
let report = metrics.get_metrics_data();§Retry semantics
fdb_transaction_on_error remains the single retry governor: backoff, max
retry delay and TransactionOption::RetryLimit
are applied by the C API, never by a Rust-side budget. A closure error asking
for a retry without a native error underneath
(RetryDecision::Retry) is routed through on_error with code 1020
(not_committed) so that it obeys the same budget.
Structs§
- Hooks collecting a
MetricsReportinto aTransactionMetrics. - The default policy: it always applies what the runner proposes, leaving
fdb_transaction_on_errorthe last word on retries. - Builder for a transactional run, returned by
Database::runner.
Enums§
- The failure a
RetryPolicyis asked about.
Traits§
- Decides what the runner does with a failed attempt.
- Observation points of the retry runner.