cancelWorkflowExecution method
Cancel workflow execution
Implementation
@override
Future<bool> cancelWorkflowExecution(String executionId) async {
final execution = _executionResults[executionId];
if (execution == null) return false;
if (execution.status == WorkflowStatus.running) {
final cancelledExecution = WorkflowExecutionResult(
workflowId: execution.workflowId,
executionId: executionId,
status: WorkflowStatus.cancelled,
result: execution.result,
error: null,
startedAt: execution.startedAt,
completedAt: DateTime.now(),
);
_executionResults[executionId] = cancelledExecution;
_eventController.add(WorkflowEvent(
executionId: executionId,
eventType: WorkflowEventType.workflowCancelled,
stepId: null,
data: null,
error: null,
timestamp: DateTime.now(),
));
return true;
}
return false;
}