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.

Methods

acquire(
key: string,
ttlMs: number
): Promise<string | null>

Attempt to acquire the lock.

release(
key: string,
token: string
): Promise<void>

Release a previously acquired lock.

Only releases if the provided token matches the held token.

Usage

import { type IDistributedLock } from "scheduler-plugin/src/index.ts";