suspendUntil method

  1. @override
Future<void> suspendUntil(
  1. String runId,
  2. String stepName,
  3. DateTime when, {
  4. Map<String, Object?>? data,
})
override

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 state = _runs[runId];
  if (state == null) return;
  _runs[runId] = state.copyWith(
    status: WorkflowStatus.suspended,
    cursor: state.cursor,
    resumeAt: when,
    suspensionData: _prepareSuspensionData(data, resumeAt: when),
    waitTopic: null,
    updatedAt: _clock.now(),
  );
  _due.putIfAbsent(when, () => <String>{}).add(runId);
}