LockProvider

Trait LockProvider 

Source
pub trait LockProvider: Send + Sync {
    type Lock: DistributedLock;

    // Required method
    fn create_lock(&self, name: &str) -> Self::Lock;
}
Expand description

Factory for creating distributed locks by name.

Providers encapsulate backend configuration, allowing application code to be backend-agnostic.

§Example

// Configure once at startup
let provider = PostgresLockProvider::new(connection_string);

// Create locks by name anywhere in the application
let lock = provider.create_lock("my-resource");
let handle = lock.acquire(None).await?;

Required Associated Types§

Source

type Lock: DistributedLock

The lock type created by this provider.

Required Methods§

Source

fn create_lock(&self, name: &str) -> Self::Lock

Creates a lock with the given name.

Implementors§