Skip to main content

duroxide_pg/
lib.rs

1//! # Duroxide PostgreSQL Provider
2//!
3//! A PostgreSQL-based provider implementation for [Duroxide](https://crates.io/crates/duroxide),
4//! a durable task orchestration framework for Rust.
5//!
6//! ## Usage
7//!
8//! ```rust,no_run
9//! use duroxide_pg::PostgresProvider;
10//! use duroxide::runtime::Runtime;
11//! use std::sync::Arc;
12//!
13//! # async fn example() -> anyhow::Result<()> {
14//! // Create a provider with the database URL
15//! let provider = PostgresProvider::new("postgres://user:password@localhost:5432/mydb").await?;
16//!
17//! // Use with the Duroxide runtime
18//! // let runtime = Runtime::start_with_store(Arc::new(provider), activity_registry, orchestration_registry).await;
19//! # Ok(())
20//! # }
21//! ```
22//!
23//! ## Custom Schema
24//!
25//! To isolate data in a specific PostgreSQL schema (useful for multi-tenant deployments):
26//!
27//! ```rust,no_run
28//! use duroxide_pg::PostgresProvider;
29//!
30//! # async fn example() -> anyhow::Result<()> {
31//! let provider = PostgresProvider::new_with_schema(
32//!     "postgres://user:password@localhost:5432/mydb",
33//!     Some("my_schema"),
34//! ).await?;
35//! # Ok(())
36//! # }
37//! ```
38//!
39//! ## Configuration
40//!
41//! | Environment Variable | Description | Default |
42//! |---------------------|-------------|---------|
43//! | `DUROXIDE_PG_POOL_MAX` | Maximum connection pool size | `10` |
44//!
45//! ## Features
46//!
47//! - Automatic schema migration on startup
48//! - Connection pooling via sqlx
49//! - Custom schema support for multi-tenant isolation
50//! - Full implementation of the Duroxide `Provider` and `ProviderAdmin` traits
51
52pub mod migrations;
53pub mod provider;
54
55pub use provider::PostgresProvider;