v0.15.0
Add seek_with_interrupt method for user-controlled worker cancellation
New Features
- User-controlled worker cancellation: Added
seek_with_interruptmethod for external cancellation control - Public
Interruptstruct: Now exported from theworkflowmodule with comprehensive documentation - Graceful cancellation: Workers can be cancelled mid-execution while preserving worker ownership
- Interrupt propagation: When interrupted, cancellation is properly propagated to running workflow tasks
Usage Example
use mahler::workflow::Interrupt;
let interrupt = Interrupt::new();
let interrupt_clone = interrupt.clone();
// Start worker with interrupt control
let worker_handle = tokio::spawn(async move {
worker.seek_with_interrupt(target_state, interrupt).await
});
// Cancel from another task
tokio::spawn(async move {
tokio::time::sleep(Duration::from_secs(5)).await;
interrupt_clone.trigger(); // Cancel the worker
});
let result = worker_handle.await.unwrap().unwrap();
assert_eq!(result.status(), &SeekStatus::Interrupted);Compatibility
- Fully backward compatible: Existing
seek_targetusage continues to work unchanged - No breaking changes: All existing APIs remain the same
Users can now create an Interrupt, pass it to seek_with_interrupt, and trigger cancellation from external tasks or threads. This enables better control over long-running worker operations and graceful shutdown scenarios.
List of commits
b6cf117 (Make Interrupt struct public, 2025-06-11)
519ec0b (Add seek_with_interrupt method for user-controlled worker cancellation, 2025-06-11)