pub async fn init(
database_url: &str,
) -> Result<(DatabaseConnection, Vec<RecoveredTask>), DurableError>Expand description
Initialize durable: connect to Postgres, run migrations, start heartbeat, and recover stale tasks from prior crashes.
After this call, Ctx::start automatically tags tasks with the executor
ID for crash recovery. Recovered tasks from prior crashes are returned so
the caller can resume them with Ctx::from_id.
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?;
// Resume any interrupted workflows
for task in &recovered {
let ctx = Ctx::from_id(&db, task.id).await?;
// re-run your workflow function with ctx...
}
// Start new workflows — executor_id is set automatically
let ctx = Ctx::start(&db, "my_workflow", None).await?;