[][src]Struct please::PleaseHandle

pub struct PleaseHandle<P: ConnectionProvider> { /* fields omitted */ }

This handle identifies a long-running operation using a unique integer.

Methods

impl<P: ConnectionProvider> PleaseHandle<P>
[src]

Construct a new handle using the specified connection provider.

The connection provider is typically a connection pool of some kind, or it may be implemented by establishing a new connection each time.

The title is used as a human-readable name to identify this handle. This is useful if you are inspecting the database, or for logging expired handles.

Convenience constructor.

Equivalent to calling perform_cleanup followed by new. If you wish to handle expired handles (eg. record them to a log) then call the methods individually.

Constructor to use from within an existing transaction.

Allows conditionally creating a handle without losing the atomicity of a single transaction.

Explicitly clean up old handles. It is recommended to call this before creating a new handle.

This function returns the expired handles (if any) so that you can log them or use them for debugging.

Run a transaction as part of the operation this handle represents.

After beginning the transaction, this method validates that the handle has not expired, whilst also refreshing the expiry and taking a lock on the row, to prevent it being expired by another thread whilst this transaction is in progress.

The callback is passed two arguments: a reference to the connection, and the integer ID of this handle. Currently this is the only way to access the handle's ID as it is not recommended to use this ID outside of a transaction.

Refreshes the handle, resetting the time before it will be automatically closed.

This is equivalent to running an empty transaction.

Expire the handle. Future operations on this handle will fail with the error Expired.

Useful for testing.

Close the handle, allowing any errors to be handled.

This is automatically called when a handle is dropped, but in that case errors are silently ignored.

Get the ID of this handle.

A good rule of thumb is to never use this outside of a transaction, as in that case it may not have been recently validated.

Trait Implementations

impl<P: Debug + ConnectionProvider> Debug for PleaseHandle<P>
[src]

Formats the value using the given formatter. Read more

impl<P: ConnectionProvider> Drop for PleaseHandle<P>
[src]

Closes the handle, ignoring any errors that might have occurred.

Auto Trait Implementations

impl<P> Send for PleaseHandle<P> where
    P: Send

impl<P> Sync for PleaseHandle<P> where
    P: Sync

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Important traits for &'a mut R

Immutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Important traits for &'a mut R

Mutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> IntoSql for T

Convert self to an expression for Diesel's query builder. Read more

Important traits for &'a mut R

Convert &self to an expression for Diesel's query builder. Read more