ClusterCron unstable
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.
With calculateNextRunFromPrevious, every run is processed by a single
entity per cron job, so runs never overlap and are caught up in order. The
scheduled time of the current run is available through
CurrentScheduledTime.
Constructors
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<Exclude<R, CurrentScheduledTime>, Scope>>Services
CurrentScheduledTime
unstableService tag for the scheduled time of the cron run currently executing.
When to use
Use to read the time the current run was scheduled for, inside the
execute effect of make.
Signature
declare class CurrentScheduledTime extends Shape<"effect/cluster/ClusterCron/CurrentScheduledTime", Utc, this> { constructor(_: never);}