pub struct Waker { /* private fields */ }Expand description
Periodic task that wakes Sleeping runs whose scheduled_at has passed.
§Examples
use std::sync::Arc;
use std::time::Duration;
use ironflow_api::waker::Waker;
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, Arc::new(ClaudeCodeProvider::new())));
let waker = Waker::new(engine).interval(Duration::from_secs(5));
tokio::spawn(waker.run(CancellationToken::new()));Implementations§
Source§impl Waker
impl Waker
Sourcepub fn new(engine: Arc<Engine>) -> Self
pub fn new(engine: Arc<Engine>) -> Self
Create a waker with the default interval and batch size.
§Examples
use std::sync::Arc;
use ironflow_api::waker::Waker;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_engine::engine::Engine;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let engine = Arc::new(Engine::new(store, Arc::new(ClaudeCodeProvider::new())));
let waker = Waker::new(engine);Sourcepub fn interval(self, interval: Duration) -> Self
pub fn interval(self, interval: Duration) -> Self
Set how often due runs are collected.
§Examples
use std::sync::Arc;
use std::time::Duration;
use ironflow_api::waker::Waker;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_engine::engine::Engine;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let engine = Arc::new(Engine::new(store, Arc::new(ClaudeCodeProvider::new())));
let waker = Waker::new(engine).interval(Duration::from_secs(5));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 wakes.
§Examples
use std::sync::Arc;
use ironflow_api::waker::Waker;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_engine::engine::Engine;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let engine = Arc::new(Engine::new(store, Arc::new(ClaudeCodeProvider::new())));
let waker = Waker::new(engine).batch_size(10);Sourcepub async fn run(self, shutdown: CancellationToken)
pub async fn run(self, shutdown: CancellationToken)
Run the wake-up loop until shutdown is cancelled.
Store errors are logged and the loop keeps going: a transient database failure must not leave runs asleep forever.
§Examples
use ironflow_api::waker::Waker;
use tokio_util::sync::CancellationToken;
let shutdown = CancellationToken::new();
tokio::spawn(waker.run(shutdown.clone()));
shutdown.cancel();Auto Trait Implementations§
impl !RefUnwindSafe for Waker
impl !UnwindSafe for Waker
impl Freeze for Waker
impl Send for Waker
impl Sync for Waker
impl Unpin for Waker
impl UnsafeUnpin for Waker
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