cancelSignals method
Cancels all pending signals for a given execution.
Implementation
Future<void> cancelSignals(String workflowExecutionId) async {
final signals = await _store.loadPendingSignals(workflowExecutionId);
for (final signal in signals) {
await _store.saveSignal(
signal.copyWith(status: SignalStatus.expired),
);
}
// Cancel any active completers and timeouts for this execution
final keysToRemove = <String>[];
for (final key in _completers.keys) {
if (key.startsWith('$workflowExecutionId:')) {
keysToRemove.add(key);
}
}
for (final key in keysToRemove) {
_timeoutTimers[key]?.cancel();
_timeoutTimers.remove(key);
final completer = _completers.remove(key);
if (completer != null && !completer.isCompleted) {
completer.completeError(
WorkflowCancelledException(workflowExecutionId),
);
}
}
}