pub struct Reaper { /* private fields */ }Expand description
Periodic task that requeues runs whose worker lease expired.
§Examples
use std::sync::Arc;
use std::time::Duration;
use ironflow_api::reaper::Reaper;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_engine::engine::Engine;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
use tokio_util::sync::CancellationToken;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let engine = Arc::new(Engine::new(store.clone(), Arc::new(ClaudeCodeProvider::new())));
let reaper = Reaper::new(store, engine).interval(Duration::from_secs(30));
tokio::spawn(reaper.run(CancellationToken::new()));Implementations§
Source§impl Reaper
impl Reaper
Sourcepub fn new(store: Arc<dyn Store>, engine: Arc<Engine>) -> Self
pub fn new(store: Arc<dyn Store>, engine: Arc<Engine>) -> Self
Create a reaper with the default interval and batch size.
Sourcepub fn interval(self, interval: Duration) -> Self
pub fn interval(self, interval: Duration) -> Self
Set how often expired leases are collected.
Keep it well below the worker lease TTL, otherwise recovery takes longer than the TTL suggests.
Sourcepub fn batch_size(self, batch_size: u32) -> Self
pub fn batch_size(self, batch_size: u32) -> Self
Set how many runs a single tick recovers.
Sourcepub async fn run(self, shutdown: CancellationToken)
pub async fn run(self, shutdown: CancellationToken)
Run the recovery loop until shutdown is cancelled.
Store errors are logged and the loop keeps going: a transient database failure must not silently stop recovery.
Auto Trait Implementations§
impl !RefUnwindSafe for Reaper
impl !UnwindSafe for Reaper
impl Freeze for Reaper
impl Send for Reaper
impl Sync for Reaper
impl Unpin for Reaper
impl UnsafeUnpin for Reaper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more