Skip to main content

init

Function init 

Source
pub async fn init(
    database_url: &str,
) -> Result<(DatabaseConnection, Vec<RecoveredTask>), DurableError>
Expand description

Initialize durable: connect to Postgres, run migrations, start heartbeat, recover stale tasks, and auto-resume registered workflows.

After this call, Ctx::start automatically tags tasks with the executor ID for crash recovery. Recovered root workflows that have a matching #[durable::workflow] registration are automatically spawned as tokio tasks.

Uses HeartbeatConfig::default() (60 s heartbeat, 180 s staleness). For custom intervals use init_with_config.

let (db, recovered) = durable::init("postgres://localhost/mydb").await?;