pub struct LockClient { /* private fields */ }Expand description
A handle to the distributed lock service.
Cloning is cheap (Arc bump) and all clones share the same backend, clock,
and node identity.
Implementations§
Source§impl LockClient
impl LockClient
Sourcepub async fn connect(config: LockConfig) -> Result<Self>
pub async fn connect(config: LockConfig) -> Result<Self>
Connect using the default InMemoryBackend — single-process locking
only. For real distributed locking, connect an EtcdBackend (behind
the etcd feature) and pass it to connect_with.
Sourcepub async fn connect_with(
config: LockConfig,
backend: Arc<dyn LockBackend>,
) -> Result<Self>
pub async fn connect_with( config: LockConfig, backend: Arc<dyn LockBackend>, ) -> Result<Self>
Connect using an explicit LockBackend (e.g. InMemoryBackend for
tests, or EtcdBackend for a real cluster). Bypasses discovery
entirely.
Sourcepub async fn lock(&self, resource: &str) -> LockBuilder<'_>
pub async fn lock(&self, resource: &str) -> LockBuilder<'_>
Begin acquiring resource. Returns a LockBuilder for fluent
configuration; nothing is acquired until
acquire is awaited.
Note: this is async to match the spec signature, though it currently
does no awaiting itself.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LockClient
impl !UnwindSafe for LockClient
impl Freeze for LockClient
impl Send for LockClient
impl Sync for LockClient
impl Unpin for LockClient
impl UnsafeUnpin for LockClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more