Skip to main content

Crate nestrs_locks

Crate nestrs_locks 

Source
Expand description

NestJS @nestjs/locks analogue — lease-based distributed locks for single-runner cron and critical sections.

§Example

ⓘ
use nestrs_locks::{LocksModule, LocksOptions, LocksService};

let dm = LocksModule::register(LocksOptions::default());
if let Some(guard) = locks.try_acquire("cron:nightly").await {
    // exclusive work
    guard.release().await;
}

Choose default_ttl carefully: shorter than tolerable duplicate work after a crash, longer than healthy job duration (or extend the lease). Redis store: feature cache-redis.

Umbrella feature: nestrs / locks → nestrs::locks.

Structs§

DynamicModule
Runtime-composed module unit for conditional imports (feature flags, env switches, plugins).
InMemoryLockStore
LockGuard
LocksModule
LocksOptions
LocksService
High-level lock service (NestJS LocksService analogue).
ProviderRegistry
SharedInMemoryLockStore
Arc-backed in-memory store (preferred).

Traits§

Injectable
Application service or provider type constructed through the DI container.
LockStore

Type Aliases§

SharedLockStore