foundationdb::runner

Struct TransactionRunner

Source
pub struct TransactionRunner<'a, H = (), P = NativeRetryPolicy> { /* private fields */ }
Expand description

Builder for a transactional run, returned by Database::runner.

It assembles the RunnerHooks and the RetryPolicy of a single call to run: no hooks and NativeRetryPolicy by default. Both are borrowed, so the same hooks and policy can be reused across runs (mind MetricsHooks, which times the run from its own construction).

db.runner()
    .run(|trx, _| async move {
        trx.set(b"key", b"value");
        Ok::<_, FdbBindingError>(())
    })
    .await

Implementations§

Source§

impl<'a, H, P> TransactionRunner<'a, H, P>

Source

pub fn hooks<H2>(self, hooks: &'a H2) -> TransactionRunner<'a, H2, P>

Observes the run with hooks, replacing any hooks set before.

Stack several of them with a tuple: .hooks(&(first, second)).

Source

pub fn retry_policy<P2>(self, policy: &'a P2) -> TransactionRunner<'a, H, P2>

Decides the retries with policy instead of NativeRetryPolicy.

Source

pub async fn run<F, Fut, T, E>(self, closure: F) -> Result<T, E>
where F: Fn(RetryableTransaction, MaybeCommitted) -> Fut, Fut: Future<Output = Result<T, E>>, E: RetryableError, H: RunnerHooks, P: RetryPolicy<E>,

Runs closure in a transaction, retrying it until it commits or the error is fatal.

See Database::run for the semantics of the closure, its error type and the retries.

Auto Trait Implementations§

§

impl<'a, H, P> Freeze for TransactionRunner<'a, H, P>

§

impl<'a, H, P> RefUnwindSafe for TransactionRunner<'a, H, P>

§

impl<'a, H, P> Send for TransactionRunner<'a, H, P>
where H: Sync, P: Sync,

§

impl<'a, H, P> Sync for TransactionRunner<'a, H, P>
where H: Sync, P: Sync,

§

impl<'a, H, P> Unpin for TransactionRunner<'a, H, P>

§

impl<'a, H, P> UnwindSafe for TransactionRunner<'a, H, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.