Skip to content

ClusterCron

Runs recurring cron jobs through cluster sharding.

This module turns a Cron.Cron schedule into a Layer that coordinates one recurring job across a cluster. It registers a singleton for the initial scheduling step and a persisted entity message for each run. This is useful for distributed maintenance work where the job should be owned by the cluster rather than by every runner independently.

1 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates a layer that runs a cron job through the cluster sharding system.

Details

The job is scheduled as persisted entity messages, with an initial singleton scheduling step and optional controls for shard group, next-run calculation, and skipping stale scheduled runs.

Signature

declare function make<E, R>(options: {
  readonly calculateNextRunFromPrevious?: boolean;
  readonly cron: Cron;
  readonly execute: Effect<void, E, R>;
  readonly name: string;
  readonly shardGroup?: string;
  readonly skipIfOlderThan?: Input;
}): Layer<never, never, Sharding | Exclude<R, Scope>>;