Struct dynalock::DistLock
[−]
[src]
pub struct DistLock<Driver> { /* fields omitted */ }
The distributed lock structure that holds all the internal lock state and information.
This is the entry point to this library and should be used to hold a lock on a shared resource.
Examples
use std::time::Duration; use dynalock::DistLock; let mut dlock = DistLock::new( "some driver", Duration::from_secs(10) );
Methods
impl<Driver> DistLock<Driver>
[src]
pub fn new(driver: Driver, duration: Duration) -> Self
[src]
Initialize a new DistLock structure and return it.
This static method accepts a Driver
and std::time::Duration
as parameters.
The duration
parameter is used to describe the time for which the lock should be held.
pub fn driver(&mut self) -> &mut Driver
[src]
Return a mutable reference to the underlying driver
field.
pub fn duration(&self) -> Duration
[src]
Return the configured lease duration for the lock.
Trait Implementations
impl<P, D> Locking for DistLock<DynamoDbDriver<P, D>> where
P: ProvideAwsCredentials + 'static,
D: DispatchSignedRequest + 'static,
[src]
P: ProvideAwsCredentials + 'static,
D: DispatchSignedRequest + 'static,
type AcquireLockInputType = DynamoDbLockInput
Associated type for the acquire_lock
method input type.
type RefreshLockInputType = DynamoDbLockInput
Associated type for the refresh_lock
method input type.
type ReleaseLockInputType = DynamoDbLockInput
Associated type for the release_lock
method input type.
fn acquire_lock(
&mut self,
input: &Self::AcquireLockInputType
) -> Result<Instant, DynaError>
[src]
&mut self,
input: &Self::AcquireLockInputType
) -> Result<Instant, DynaError>
Try to acquire a lock on a shared resource. Read more
fn refresh_lock(
&mut self,
input: &Self::RefreshLockInputType
) -> Result<(), DynaError>
[src]
&mut self,
input: &Self::RefreshLockInputType
) -> Result<(), DynaError>
Try to refresh the current lock data structure. Read more
fn release_lock(
&mut self,
input: &Self::ReleaseLockInputType
) -> Result<(), DynaError>
[src]
&mut self,
input: &Self::ReleaseLockInputType
) -> Result<(), DynaError>
This optional method is only useful in rare situations and highly depends on the provider's implementation and primitives supported. Providers should implement this method to release the lock by clearing the fence token. Read more
fn remaining(&self, instant: Instant) -> Option<Duration>
[src]
When acquire_lock
is successful it returns an std::time::Instant
which is used to track the time from when the lease was issued. This method is used to safely calculate the time or duration left since acquire_lock
was called. If the return value is None
this means that the lock lease has expired and you must stop mutating the shared resource immediately. Read more