adk_workflow (erlang_adk v0.7.0)
View SourceDeclarative, bounded workflow API.
A compiled workflow is immutable. Each started workflow has a detached coordinator which owns its checkpoint and terminal outcome; potentially blocking actions execute in monitored workers. Public checkpoints contain JSON-safe values only and can be used to resume from the last committed boundary with the remaining non-time budgets intact.
Summary
Functions
Validate and compile a declarative workflow specification.
Delete an unowned durable invocation from its ledger.
Read persisted invocation state without requiring a live coordinator.
Claim and resume a durable workflow by stable invocation ID.
Start a checkpointed workflow with a stable durable invocation ID.
Types
-type checkpoint() :: map().
-type outcome() :: {completed, map(), checkpoint()} | {paused, map(), checkpoint()} | {failed, term(), checkpoint()} | {timed_out, checkpoint()} | {cancelled, term(), checkpoint()}.
-type workflow_ref() :: pid().
Functions
-spec await(workflow_ref()) -> outcome() | {error, term()}.
-spec await(workflow_ref(), timeout()) -> outcome() | {error, term()}.
-spec cancel(workflow_ref()) -> ok | {error, term()}.
-spec cancel(workflow_ref(), term()) -> ok | {error, term()}.
-spec checkpoint(workflow_ref()) -> {ok, checkpoint()} | {error, term()}.
Validate and compile a declarative workflow specification.
Delete an unowned durable invocation from its ledger.
Read persisted invocation state without requiring a live coordinator.
-spec resume(map(), checkpoint()) -> {ok, workflow_ref()} | {error, term()}.
-spec resume(map(), checkpoint(), map()) -> {ok, workflow_ref()} | {error, term()}.
-spec resume_invocation(binary(), map(), map()) -> {ok, workflow_ref()} | {error, term()}.
Claim and resume a durable workflow by stable invocation ID.
Exactly one live coordinator can own an invocation. A dead local owner is replaced immediately; a remote owner can be replaced only after its lease expires. Completed invocations are immutable and cannot be resumed.
-spec start(map(), map()) -> {ok, workflow_ref()} | {error, term()}.
-spec start(map(), map(), map()) -> {ok, workflow_ref()} | {error, term()}.
Start a checkpointed workflow with a stable durable invocation ID.
Opts must contain ledger => {Module, Handle}, where Module implements adk_invocation_ledger. The returned ID, unlike the coordinator pid, stays valid across coordinator and VM/application restarts. An optional binary invocation_id may be supplied for upstream idempotent creation.
-spec status(workflow_ref()) -> {ok, map()} | {error, term()}.