ClusterWorkflowEngine
The cluster workflow engine runs durable workflows on top of cluster sharding and message storage. It adapts WorkflowEngine.WorkflowEngine so workflow executions, activities, deferred completions, resumes, interrupts, and durable clock wakeups are represented as persisted cluster entity messages.
Constructors
Signature
declare const make: Effect<
{
readonly activityExecute: <Success extends Constraint, Error extends Constraint, R>(
activity: Activity<Success, Error, R>,
attempt: number,
) => Effect<
Result<Success["Type"], Error["Type"]>,
never,
WorkflowInstance | R | Success["DecodingServices"] | Error["DecodingServices"]
>;
readonly deferredDone: <Success extends Constraint, Error extends Constraint>(
deferred: DurableDeferred<Success, Error>,
options: {
readonly deferredName: string;
readonly executionId: string;
readonly exit: Exit<Success["Type"], Error["Type"]>;
readonly workflowName: string;
},
) => Effect<void, never, Success["EncodingServices"] | Error["EncodingServices"]>;
readonly deferredResult: <Success extends Constraint, Error extends Constraint>(
deferred: DurableDeferred<Success, Error>,
) => Effect<Option<Exit<Success["Type"], Error["Type"]>>, never, WorkflowInstance>;
readonly execute: <
Name extends string,
Payload extends AnyStructSchema,
Success extends Top,
Error extends Top,
Discard extends boolean = false,
>(
workflow: Workflow<Name, Payload, Success, Error>,
options: {
readonly discard?: Discard;
readonly executionId: string;
readonly payload: Payload["Type"];
readonly suspendedRetrySchedule?: Schedule<any, unknown, never, never>;
},
) => Effect<
Discard extends true ? string : Success["Type"],
Error["Type"],
Payload["EncodingServices"] | Success["DecodingServices"] | Error["DecodingServices"]
>;
readonly interrupt: (workflow: Any, executionId: string) => Effect<void>;
readonly interruptUnsafe: (workflow: Any, executionId: string) => Effect<void>;
readonly poll: <
Name extends string,
Payload extends AnyStructSchema,
Success extends Top,
Error extends Top,
>(
workflow: Workflow<Name, Payload, Success, Error>,
executionId: string,
) => Effect<
Option<Result<Success["Type"], Error["Type"]>>,
never,
Success["DecodingServices"] | Error["DecodingServices"]
>;
readonly register: <
Name extends string,
Payload extends AnyStructSchema,
Success extends Top,
Error extends Top,
R,
>(
workflow: Workflow<Name, Payload, Success, Error>,
execute: (
payload: Payload["Type"],
executionId: string,
) => Effect<Success["Type"], Error["Type"], R>,
) => Effect<
void,
never,
| Scope
| Exclude<R, Scope | WorkflowEngine | WorkflowInstance | Execution<Name>>
| Payload["DecodingServices"]
| Payload["EncodingServices"]
| Success["DecodingServices"]
| Success["EncodingServices"]
| Error["DecodingServices"]
| Error["EncodingServices"]
>;
readonly resume: (workflow: Any, executionId: string) => Effect<void>;
readonly scheduleClock: (
workflow: Any,
options: {
readonly clock: DurableClock;
readonly executionId: string;
},
) => Effect<void>;
},
never,
Scope | Sharding | MessageStorage
>;Layers
Layer that provides WorkflowEngine.WorkflowEngine using the cluster workflow engine implementation.
Details
It requires cluster sharding and message storage, and also registers the durable clock entity used for workflow wakeups.
Signature
declare const layer: Layer.Layer<
WorkflowEngine.WorkflowEngine,
never,
Sharding.Sharding | MessageStorage
>;
Creates a
WorkflowEngineimplementation backed by cluster sharding and message storage.Details
Workflow executions, activities, deferred completions, resumes, interrupts, and durable clock wakeups are coordinated through persisted cluster entities.