Expand description
PostgreSQL-backed durable execution for the Everruns ecosystem: a claimable task queue, an event log, schedules, a worker pool, and retries and circuit breakers.
State lives in PostgreSQL. Workers claim tasks with
SELECT ... FOR UPDATE SKIP LOCKED, and anything a dead worker held is
reclaimed and retried, so work survives crashes and restarts with no
infrastructure beyond the database.
WorkflowEventStoreis the storage contract, split into focused traits such asEventLog,TaskQueueandWorkerRegistry.PostgresWorkflowEventStoreis the production store andInMemoryWorkflowEventStorethe test double.WorkerPoolclaims and runs tasks with bounded concurrency, heartbeats and backpressure;StaleTaskReaperreclaims work from dead workers.DurableSchedulerfires cron and interval schedules.RetryPolicy,ActivityOptionsandDistributedCircuitBreakercontrol retries, timeouts and failure isolation.
The crate knows workflows and tasks as durable records, and nothing about the domain built on top of it. The Everruns worker’s task loop and the server’s cluster jobs drive the task queue directly and own their own semantics.
§Example
The crate ships its own PostgreSQL schema. Apply it with
PostgresWorkflowEventStore::migrate, which is idempotent and safe to call
on every start-up, then enqueue and claim work.
use everruns_durable::prelude::*;
use serde_json::json;
let pool = sqlx::PgPool::connect("postgres://localhost/my_app").await?;
PostgresWorkflowEventStore::migrate(&pool).await?;
let store = PostgresWorkflowEventStore::new(pool);
let workflow_id = uuid::Uuid::now_v7();
store.create_workflow(workflow_id, "order", json!({}), None).await?;
store
.enqueue_task(TaskDefinition {
workflow_id: Some(workflow_id),
activity_id: "charge".into(),
activity_type: "charge_card".into(),
input: json!({ "amount": 42 }),
options: ActivityOptions::default(),
})
.await?;
let claimed = store.claim_task("worker-1", &["charge_card".into()], 1).await?;Re-exports§
pub use activity::ActivityError;pub use maintenance::NoopReapHandler;pub use maintenance::ReapHandler;pub use maintenance::ReaperConfig;pub use maintenance::StaleTaskReaper;pub use maintenance::reap_stale_tasks;pub use persistence::CircuitBreakerState;pub use persistence::CircuitBreakers;pub use persistence::ClaimedTask;pub use persistence::CreateScheduleRow;pub use persistence::DeadLetters;pub use persistence::DeadTaskInfo;pub use persistence::DlqEntry;pub use persistence::DlqFilter;pub use persistence::DurableAdmin;pub use persistence::EventLog;pub use persistence::HeartbeatResponse;pub use persistence::InMemoryWorkflowEventStore;pub use persistence::Pagination;pub use persistence::PostgresWorkflowEventStore;pub use persistence::ReclaimResult;pub use persistence::ScheduleExecutionFilter;pub use persistence::ScheduleExecutionRow;pub use persistence::ScheduleExecutionStatus;pub use persistence::ScheduleFilter;pub use persistence::ScheduleRow;pub use persistence::ScheduleStats;pub use persistence::ScheduleTargetType;pub use persistence::SchedulerInstanceInfo;pub use persistence::Schedules;pub use persistence::SealedTaskInfo;pub use persistence::StoreError;pub use persistence::SystemHealth;pub use persistence::TaskDefinition;pub use persistence::TaskFailureOutcome;pub use persistence::TaskFilter;pub use persistence::TaskInfo;pub use persistence::TaskQueue;pub use persistence::TaskStatus;pub use persistence::TraceContext;pub use persistence::UpdateSchedule;pub use persistence::WORKER_HEARTBEAT_TIMEOUT_SECS;pub use persistence::WorkerFilter;pub use persistence::WorkerHeartbeat;pub use persistence::WorkerInfo;pub use persistence::WorkerRegistry;pub use persistence::WorkflowEventInfo;pub use persistence::WorkflowEventStore;pub use persistence::WorkflowFilter;pub use persistence::WorkflowInfo;pub use persistence::WorkflowInfoExtended;pub use persistence::WorkflowStatus;pub use persistence::begin_transaction;pub use persistence::commit_in_place;pub use persistence::commit_transaction;pub use reliability::CircuitBreakerConfig;pub use reliability::CircuitBreakerError;pub use reliability::CircuitState;pub use reliability::DistributedCircuitBreaker;pub use reliability::RetryPolicy;pub use scheduler::Cadence;pub use scheduler::DurableScheduler;pub use scheduler::EnsureOutcome;pub use scheduler::ScheduleSpec;pub use scheduler::SchedulerConfig;pub use scheduler::SchedulerError;pub use scheduler::disable_schedule;pub use scheduler::ensure_schedule;pub use scheduler::find_schedule;pub use scheduler::next_trigger_after;pub use worker::WorkerPool;pub use worker::WorkerPoolConfig;pub use worker::WorkerPoolError;pub use workflow::ActivityOptions;pub use workflow::WorkflowError;pub use workflow::WorkflowEvent;pub use task_events::append_event;pub use task_events::record_activity_completed;pub use task_events::record_activity_failed;pub use task_events::record_activity_started;pub use task_events::record_workflow_cancelled;pub use task_events::record_workflow_completed;pub use task_events::record_workflow_failed;
Modules§
- activity
- Activity errors
- maintenance
- Stale-task reaping: return abandoned tasks to the queue and terminalize the workflows whose tasks died.
- persistence
- Persistence layer for durable execution
- prelude
- Prelude for common imports
- reliability
- Reliability patterns for durable execution
- schedule_
transaction - Join schedule configuration writes to a host’s transaction on the same pool. The host owns BEGIN/COMMIT/rollback. Worker claims keep their own connections.
- scheduler
- Scheduler component for scheduled task execution
- task_
events - Task lifecycle event recording
- worker
- Worker pool for task execution
- workflow
- Workflow abstractions and types
Enums§
- Update
Field - A field in an update operation that can be unchanged, cleared, or set.
Type Aliases§
- Postgres
Pool - PostgreSQL pool passed by an owning host to the durable store API.