PostgresWorkflowStore class
PostgreSQL-backed WorkflowStore implementation using ormed ORM.
Properties
Methods
-
cancel(
String runId, {String? reason}) → Future< void> -
Transitions the run to
WorkflowStatus.cancelled. -
claimRun(
String runId, {required String ownerId, Duration leaseDuration = const Duration(seconds: 30)}) → Future< bool> - Attempts to claim a run for execution with a lease.
-
close(
) → Future< void> - Closes the workflow store and releases database resources.
-
createRun(
{required String workflow, required Map< String, Object?> params, String? parentRunId, Duration? ttl, WorkflowCancellationPolicy? cancellationPolicy}) → Future<String> - Creates a new workflow run record and returns its run id.
-
dueRuns(
DateTime now, {int limit = 256}) → Future< List< String> > -
Returns run identifiers whose wake-up time is at or before
now. -
get(
String runId) → Future< RunState?> -
Fetches the persisted run state for
runId, ornullif missing. -
listRunnableRuns(
{DateTime? now, int limit = 50, int offset = 0}) → Future< List< String> > - Returns runnable run identifiers filtered by status and lease availability.
-
listRuns(
{String? workflow, WorkflowStatus? status, int limit = 50, int offset = 0}) → Future< List< RunState> > -
Returns recent runs filtered by
workflowand/orstatus. -
listSteps(
String runId) → Future< List< WorkflowStepEntry> > - Returns persisted step results for inspection/debugging.
-
listWatchers(
String topic, {int limit = 256}) → Future< List< WorkflowWatcher> > -
Lists outstanding watchers for
topic(primarily for operator tooling). The metadata helps CLIs and dashboards explain why a run is waiting. -
markCompleted(
String runId, Object? result) → Future< void> -
Marks the run as completed with the provided
result. -
markFailed(
String runId, Object error, StackTrace stack, {bool terminal = false}) → Future< void> -
Marks the run as failed and records
errorandstack. -
markResumed(
String runId, {Map< String, Object?> ? data}) → Future<void> - Clears suspension metadata when the run is ready to execute again.
-
markRunning(
String runId, {String? stepName}) → Future< void> -
Marks the run as running and optionally sets the active
stepName. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readStep<
T> (String runId, String stepName) → Future< T?> -
Reads the persisted checkpoint value for
stepName. -
registerWatcher(
String runId, String stepName, String topic, {DateTime? deadline, Map< String, Object?> ? data}) → Future<void> -
Registers a durable watcher for
topicso the runtime can resumestepNamewhen an event is emitted. -
releaseRun(
String runId, {required String ownerId}) → Future< void> -
Releases the lease on
runIdwhen owned byownerId. -
renewRunLease(
String runId, {required String ownerId, Duration leaseDuration = const Duration(seconds: 30)}) → Future< bool> -
Renews the lease for
runIdwhen owned byownerId. -
resolveWatchers(
String topic, Map< String, Object?> payload, {int limit = 256}) → Future<List< WorkflowWatcherResolution> > -
Resolves watchers listening on
topic, persistingpayloadand marking runs ready to resume atomically. Returns the resolved watchers so the runtime can enqueue follow-up work. -
rewindToStep(
String runId, String stepName) → Future< void> -
Rewinds a run so the given
stepName(and subsequent steps) will execute again on the next resume. -
runsWaitingOn(
String topic, {int limit = 256}) → Future< List< String> > -
Returns run identifiers currently suspended on
topic. -
saveStep<
T> (String runId, String stepName, T value) → Future< void> -
Saves a checkpoint for
stepNameand refreshes the run heartbeat. -
suspendOnTopic(
String runId, String stepName, String topic, {DateTime? deadline, Map< String, Object?> ? data}) → Future<void> -
Suspends
runIdwhile awaiting an event withtopic. -
suspendUntil(
String runId, String stepName, DateTime when, {Map< String, Object?> ? data}) → Future<void> -
Suspends
runIduntil the givenwhen. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
connect(
String uri, {String schema = 'public', String namespace = 'stem', String? applicationName, TlsConfig? tls, Uuid? uuid, WorkflowClock clock = const SystemWorkflowClock()}) → Future< PostgresWorkflowStore> - Connects to a PostgreSQL database and ensures workflow tables exist.
-
fromDataSource(
DataSource dataSource, {String namespace = 'stem', Uuid? uuid, WorkflowClock clock = const SystemWorkflowClock(), bool runMigrations = true}) → Future< PostgresWorkflowStore> -
Creates a workflow store using an existing
DataSource.