[−][src]Struct macgyver_lock::LockOptions
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]
self,
connectable: K
) -> LockOptions<'a, K>
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,
C: RefUnwindSafe,
impl<'a, C> Send for LockOptions<'a, C> where
C: Send,
C: Send,
impl<'a, C> Sync for LockOptions<'a, C> where
C: Sync,
C: Sync,
impl<'a, C> Unpin for LockOptions<'a, C> where
C: Unpin,
C: Unpin,
impl<'a, C> UnwindSafe for LockOptions<'a, C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,