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::Worker;
11//!
12//! #[tokio::main]
13//! async fn main() -> 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 a Duroxide worker
18//!     let worker = Worker::new(provider);
19//!     // ... register orchestrations and activities, then run
20//!
21//!     Ok(())
22//! }
23//! ```
24//!
25//! ## Custom Schema
26//!
27//! To isolate data in a specific PostgreSQL schema (useful for multi-tenant deployments):
28//!
29//! ```rust,no_run
30//! use duroxide_pg::PostgresProvider;
31//!
32//! # async fn example() -> anyhow::Result<()> {
33//! let provider = PostgresProvider::new_with_schema(
34//!     "postgres://user:password@localhost:5432/mydb",
35//!     Some("my_schema"),
36//! ).await?;
37//! # Ok(())
38//! # }
39//! ```
40//!
41//! ## Configuration
42//!
43//! | Environment Variable | Description | Default |
44//! |---------------------|-------------|---------|
45//! | `DUROXIDE_PG_POOL_MAX` | Maximum connection pool size | `10` |
46//!
47//! ## Features
48//!
49//! - Automatic schema migration on startup
50//! - Connection pooling via sqlx
51//! - Custom schema support for multi-tenant isolation
52//! - Full implementation of the Duroxide `Provider` and `ProviderAdmin` traits
53
54pub mod migrations;
55pub mod provider;
56
57pub use provider::PostgresProvider;