MCPcopy
hub / github.com/node-cron/node-cron / RunCoordinator

Interface RunCoordinator

src/coordinator/run-coordinator.ts:9–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7 * across a fleet (e.g. a Redis lock), provide one via `setRunCoordinator`.
8 */
9export interface RunCoordinator {
10 /**
11 * Return `true` if THIS instance should run the fire identified by `key`,
12 * `false` to skip it (another instance handles it). Throw to fail closed
13 * (the run is skipped). `ttlMs` is a safety lease hint for lease-based
14 * coordinators (a Redis lock uses it; config-based ones ignore it).
15 */
16 shouldRun(key: string, ttlMs: number): boolean | Promise<boolean>;
17 /**
18 * Called after the run completes (success or failure); e.g. release a lock.
19 * Config-based coordinators leave it unimplemented.
20 */
21 onComplete?(key: string): void | Promise<void>;
22}
23
24/** Why a scheduled execution was skipped (carried on `execution:skipped`). */
25export type SkipReason = 'not-elected' | 'coordinator-error';

Callers 7

runCoordinatedMethod · 0.65
handleShouldRunMethod · 0.65
runCoordinatedMethod · 0.65
startMethod · 0.65

Implementers 2

EnvVarRunCoordinatorsrc/coordinator/env-var-run-coordinato
IpcRunCoordinatorsrc/coordinator/ipc-run-coordinator.ts

Calls

no outgoing calls

Tested by

no test coverage detected