Skip to content

DurableClock

Durable timers for workflow sleeps.

make creates a DurableClock with a name, duration, and deferred wake-up signal. sleep ignores zero durations, runs short sleeps through an in-memory activity, and schedules longer sleeps through the WorkflowEngine before awaiting the durable deferred tied to the clock.

3 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates a durable clock definition and its associated deferred wake-up signal.

Signature

declare function make(options: { readonly duration: Input; readonly name: string }): DurableClock;

Delays & Timeouts

sleep

Added in v4.0.0 Source

Waits inside a workflow, using an in-memory activity for durations at or below the threshold and scheduling a durable clock for longer durations.

Signature

declare const sleep: (options: {
  readonly duration: Duration.Input;
  readonly inMemoryThreshold?: Duration.Input;
  readonly name: string;
}) => Effect.Effect<void, never, WorkflowEngine | WorkflowInstance>;

Models

DurableClock interface

Added in v4.0.0 Source

Represents a durable workflow timer with a name, duration, and deferred completed when the timer wakes.

Signature

interface DurableClock {
  readonly "~effect/workflow/DurableClock": "~effect/workflow/DurableClock";
  readonly deferred: DurableDeferred<Void>;
  readonly duration: Duration;
  readonly name: string;
}