pub async fn sync_handler_schedules(
engine: &Engine,
store: &dyn Store,
) -> Result<(), StoreError>Expand description
Reconcile DB schedules with handler-declared schedules.
Performs a three-way sync at startup:
- Create DB rows for handlers that declare a schedule but have no
corresponding
source = handlerrow. - Update the cron expression when the handler’s cron changed.
- Delete orphan
source = handlerrows whose handler was removed from the code.
§Errors
Returns the first store error encountered. Changes applied before the error are kept.
§Examples
use std::sync::Arc;
use ironflow_api::schedule_sync::sync_handler_schedules;
use ironflow_engine::engine::Engine;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let engine = Engine::new(store.clone(), Arc::new(ClaudeCodeProvider::new()));
sync_handler_schedules(&engine, store.as_ref()).await?;