createRun method
Future<String>
createRun({
- required String workflow,
- required Map<
String, Object?> params, - String? runId,
- String? parentRunId,
- Duration? ttl,
- WorkflowCancellationPolicy? cancellationPolicy,
override
Creates a new workflow run and returns its generated id.
Implementation
@override
/// Creates a new workflow run and returns its generated id.
Future<String> createRun({
required String workflow,
required Map<String, Object?> params,
String? runId,
String? parentRunId,
Duration? ttl,
WorkflowCancellationPolicy? cancellationPolicy,
}) async {
final now = _clock.now();
final id = (runId != null && runId.trim().isNotEmpty)
? runId.trim()
: 'wf-${now.microsecondsSinceEpoch}-${_counter++}';
if (_runs.containsKey(id)) {
throw StateError('Workflow run "$id" already exists.');
}
_runs[id] = RunState(
id: id,
workflow: workflow,
status: WorkflowStatus.running,
cursor: 0,
params: Map.unmodifiable(params),
createdAt: now,
updatedAt: now,
suspensionData: const <String, Object?>{},
cancellationPolicy: cancellationPolicy,
);
_steps[id] = {};
return id;
}