Setu-TS
    Preparing search index...

    Interface IDistributedLock

    Distributed lock interface.

    Implementations acquire a lock before running a scheduled job handler and release it afterward. When another instance holds the lock, the fire is skipped.

    interface IDistributedLock {
        acquire(key: string, ttlMs: number): Promise<string | null>;
        isHealthy?(): Promise<boolean | undefined>;
        release(key: string, token: string): Promise<void>;
    }
    Index
    • Attempt to acquire the lock.

      Parameters

      • key: string

        The lock key

      • ttlMs: number

        Time-to-live in milliseconds

      Returns Promise<string | null>

      A unique token if acquired, or null if held by another instance

    • Probe the lock backend without acquiring a lock.

      Returns Promise<boolean | undefined>

      true if reachable, false if unreachable, or undefined when reachability cannot be determined

      0.10.0

    • Release a previously acquired lock.

      Only releases if the provided token matches the held token.

      Parameters

      • key: string

        The lock key

      • token: string

        The token returned by acquire

      Returns Promise<void>