Crate duroxide_pg

Crate duroxide_pg 

Source
Expand description

§Duroxide PostgreSQL Provider

A PostgreSQL-based provider implementation for Duroxide, a durable task orchestration framework for Rust.

§Usage

use duroxide_pg::PostgresProvider;
use duroxide::Worker;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create a provider with the database URL
    let provider = PostgresProvider::new("postgres://user:password@localhost:5432/mydb").await?;

    // Use with a Duroxide worker
    let worker = Worker::new(provider);
    // ... register orchestrations and activities, then run

    Ok(())
}

§Custom Schema

To isolate data in a specific PostgreSQL schema (useful for multi-tenant deployments):

use duroxide_pg::PostgresProvider;

let provider = PostgresProvider::new_with_schema(
    "postgres://user:password@localhost:5432/mydb",
    Some("my_schema"),
).await?;

§Configuration

Environment VariableDescriptionDefault
DUROXIDE_PG_POOL_MAXMaximum connection pool size10

§Features

  • Automatic schema migration on startup
  • Connection pooling via sqlx
  • Custom schema support for multi-tenant isolation
  • Full implementation of the Duroxide Provider and ProviderAdmin traits

Re-exports§

pub use provider::PostgresProvider;

Modules§

migrations
provider