Struct FdbTenant

Source
pub struct FdbTenant { /* private fields */ }
Expand description

A FdbTenant represents a named key-space within a database that can be interacted with transactionally.

Implementations§

Source§

impl FdbTenant

Source

pub fn get_name(&self) -> &[u8]

Returns the name of this FdbTenant.

Source

pub fn create_trx(&self) -> FdbResult<Transaction>

Creates a new transaction on the given database and tenant.

Source

pub async fn run<F, Fut, T>(&self, closure: F) -> Result<T, FdbBindingError>
where F: Fn(RetryableTransaction, bool) -> Fut, Fut: Future<Output = Result<T, FdbBindingError>>,

Runs a transactional function against this Tenant with retry logic. The associated closure will be called until a non-retryable FDBError is thrown or commit(), returns success.

Users are not expected to keep reference to the RetryableTransaction. If a weak or strong reference is kept by the user, the binding will throw an error.

§Warning: retry

It might retry indefinitely if the transaction is highly contentious. It is recommended to set the crate::options::TransactionOption::RetryLimit or crate::options::TransactionOption::RetryLimit on the transaction if the task need to be guaranteed to finish. These options can be safely set on every iteration of the closure.

§Warning: Maybe committed transactions

As with other client/server databases, in some failure scenarios a client may be unable to determine whether a transaction succeeded. You should make sure your closure is idempotent.

The closure will notify the user in case of a maybe_committed transaction in a previous run with the boolean provided in the closure.

Source

pub async fn transact<F>( &self, f: F, options: TransactOption, ) -> Result<F::Item, F::Error>

transact returns a future which retries on error. It tries to resolve a future created by caller-provided function f inside a retry loop, providing it with a newly created transaction. After caller-provided future resolves, the transaction will be committed automatically.

§Warning

It might retry indefinitely if the transaction is highly contentious. It is recommended to set TransactionOption::RetryLimit or TransactionOption::SetTimeout on the transaction if the task need to be guaranteed to finish.

Once Generic Associated Types lands in stable rust, the returned future of f won’t need to be boxed anymore, also the lifetime limitations around f might be lowered.

Trait Implementations§

Source§

impl Drop for FdbTenant

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for FdbTenant

Source§

impl Sync for FdbTenant

Auto Trait Implementations§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V