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
impl FdbTenant
Sourcepub fn create_trx(&self) -> FdbResult<Transaction>
pub fn create_trx(&self) -> FdbResult<Transaction>
Creates a new transaction on the given database and tenant.
Sourcepub async fn run<F, Fut, T>(&self, closure: F) -> Result<T, FdbBindingError>
pub async fn run<F, Fut, T>(&self, closure: F) -> 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.
Sourcepub async fn transact<F>(
&self,
f: F,
options: TransactOption,
) -> Result<F::Item, F::Error>where
F: DatabaseTransact,
pub async fn transact<F>(
&self,
f: F,
options: TransactOption,
) -> Result<F::Item, F::Error>where
F: DatabaseTransact,
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.