/** * 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. * * @stability unstable * @since 4.0.0 */ import * as Context from "../Context.ts"; import * as Duration from "../Duration.ts"; import * as Effect from "../Effect.ts"; import type * as Schema from "../Schema.ts"; import * as DurableDeferred from "./DurableDeferred.ts"; import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.ts"; declare const TypeId = "~effect/workflow/DurableClock"; /** * Represents a durable workflow timer with a name, duration, and deferred * completed when the timer wakes. * * @stability unstable * @category models * @since 4.0.0 */ export interface DurableClock { readonly [TypeId]: typeof TypeId; readonly name: string; readonly duration: Duration.Duration; readonly deferred: DurableDeferred.DurableDeferred; } /** * Creates a durable clock definition and its associated deferred wake-up * signal. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const make: (options: { readonly name: string; readonly duration: Duration.Input; }) => DurableClock; /** * Context reference containing the default `inMemoryThreshold` used by * {@link sleep} when the option is not passed. * * **Details** * * Workflow engines whose timers are always durable (for example the Cloudflare * Durable Object engine) provide `Duration.zero` so every `sleep` without an * explicit `inMemoryThreshold` schedules a durable clock. * * @stability unstable * @category services * @since 4.1.3 */ export declare const InMemoryThreshold: Context.Reference; /** * Waits inside a workflow, using an in-memory activity for durations at or * below the threshold and scheduling a durable clock for longer durations. * * @stability unstable * @category delays & timeouts * @since 4.0.0 */ export declare const sleep: (options: { readonly name: string; readonly duration: Duration.Input; /** * If the duration is less than or equal to this threshold, the clock will * be executed in memory. * * @default 60 seconds */ readonly inMemoryThreshold?: Duration.Input | undefined; }) => Effect.Effect; export {}; //# sourceMappingURL=DurableClock.d.ts.map