[][src]Struct macgyver_lock::LockOptions

pub struct LockOptions<'a, C> { /* fields omitted */ }

Builder for MacGyverLock

Methods

impl<'a, '_> LockOptions<'a, &'_ str>[src]

pub fn new(name: Cow<'a, str>, owner: Cow<'a, str>) -> Self[src]

Initialize the lock builder. name is used as the memcache key while trying to acquire the lock. owner is used to uniquely identify the current owner of the lock. Each individual user trying to acquire the lock should have a unique owner value.

impl<'a, C: Connectable> LockOptions<'a, C>[src]

pub fn with_expiry(self, expiry: u32) -> Self[src]

Set the expiry in seconds for the the lock key. The lock will be released after this number of seconds elapse. Defaults to 10 seconds.

Note: A value of 0 denotes no expiry and a value greater than 246060*30 is interpreted as a unix timestamp.

Note 2: std::time::SystemTime::now is used to check if the lock has expired when expiry is interepreted as UNIX timestamp. The check might fail if the system time has been tampered with.

If a user holding the lock panics, it could lead to a deadlock when there is no expiry.

pub fn with_connectable<K: Connectable>(
    self,
    connectable: K
) -> LockOptions<'a, K>
[src]

The memcache servers to use.

Defaults to memcache://localhost:11211

Note: The Connectable shouldn't use ASCII protocol because the underlying memcache library doesn't give a way to detect if acquiring the lock succeeded.

pub fn with_read_timeout(self, timeout: Duration) -> Self[src]

Set the read timeout of the underlying connection to the server. The value should be very small compared to the key expiry time. Otherwise, we might never acquire the lock in case of network delays.

pub fn with_write_timeout(self, timeout: Duration) -> Self[src]

Set the write timeout of the underlying connection to the server. The value should be very small compared to the expiry seconds. Otherwise, we might never acquire of the lock in case of network delays.

pub fn build(self) -> Result<MacGyverLock<'a>, LockError>[src]

Build the lock.

Auto Trait Implementations

impl<'a, C> RefUnwindSafe for LockOptions<'a, C> where
    C: RefUnwindSafe

impl<'a, C> Send for LockOptions<'a, C> where
    C: Send

impl<'a, C> Sync for LockOptions<'a, C> where
    C: Sync

impl<'a, C> Unpin for LockOptions<'a, C> where
    C: Unpin

impl<'a, C> UnwindSafe for LockOptions<'a, C> where
    C: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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