suspendUntil method
Suspends runId until the given when.
Implementations should persist data so it becomes available as
resumeData when the run wakes up.
Implementation
@override
Future<void> suspendUntil(
String runId,
String stepName,
DateTime when, {
Map<String, Object?>? data,
}) async {
final now = _clock.now().toUtc();
final metadata = _prepareSuspensionData(data, resumeAt: when);
await _connections.runInTransaction((ctx) async {
final run = await ctx
.query<StemWorkflowRun>()
.whereEquals('id', runId)
.whereEquals('namespace', namespace)
.first();
if (run != null) {
final updates = StemWorkflowRunUpdateDto(
status: WorkflowStatus.suspended.name,
resumeAt: when,
suspensionData: jsonEncode(metadata),
updatedAt: now,
).toMap();
updates['wait_topic'] = null;
await ctx.repository<StemWorkflowRun>().update(
updates,
where: StemWorkflowRunPartial(id: runId, namespace: namespace),
);
}
});
}