Skip to main content

sync_handler_schedules

Function sync_handler_schedules 

Source
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:

  1. Create DB rows for handlers that declare a schedule but have no corresponding source = handler row.
  2. Update the cron expression when the handler’s cron changed.
  3. Delete orphan source = handler rows 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?;