PendingTransaction

Structin corefastly 0.13.1View source
pub struct PendingTransaction { /* private fields */ }

A cache transaction suspended between lookup and response.

This handle is produced by TransactionLookupBuilder::execute_async().

Blocking Status

Callers can check whether or not the request was instructed to wait behind another caller by calling PendingTransaction::pending(), and can complete the request (returning a Transaction) by calling PendingTransaction::wait().

Methods

fn pending(&self) -> Result<bool, CacheError>

Returns true if this request was instructed to wait for another request to insert the looked-up item, and false otherwise.

Note that, even if pending() returns true, the Transaction returned by wait() may still be required to insert (or update) the object. This can happen if the caller providng the item called Transaction::cancel_insert_or_update() or encountered an error.

Parameters

self: &Self

Returns

fn wait(self) -> Result<Transaction, CacheError>

Returns the Transaction resulting from the lookup that produced this PendingTransaction, waiting for another caller to provide the requested item if necessary.

If a timeout was set via TransactionLookupBuilder::timeout(), this call returns CacheError::Timeout if another caller does not provide the item within the timeout; see wait_for() for the timeout semantics.

Parameters

self: Self

Returns

wait_for

View source
fn wait_for(self, timeout: Duration) -> Result<Transaction, CacheError>

Like wait(), but gives up after timeout and returns CacheError::Timeout if the lookup has not resolved by then. The timeout argument overrides any timeout set via TransactionLookupBuilder::timeout().

This bounds the time spent blocking for another caller to provide the requested item under request collapsing. It is useful when a slow or wedged caller would otherwise block this lookup: rather than blocking, the caller can time out and decide how to proceed (for example, by bypassing the cache and going directly to origin).

On timeout, the wait is abandoned and the lookup's resources are released; this PendingTransaction is consumed regardless of the outcome.

Parameters

self: Self
timeout: Duration

Returns

Auto trait implementations

Blanket implementations