Skip to main content

Crate wabot_feature_pg

Crate wabot_feature_pg 

Source
Expand description

§wabot-feature-pg

Postgres foundation — port of wabot-ts/src/feature/pg. Provides:

  • PgConfig / PgDatabase — pool construction from DATABASE_URL + WABOT_PG_*, registrable as a DI singleton.
  • PgJsonbStore — the JSONB document store every framework table uses (id / created_at / data + promoted columns), created on first use.
  • PgLocker — distributed wabot_core::lock::Locker on advisory locks; the piece that makes multi-node scheduling safe.

§What’s ported and what isn’t

wabot-ts’s feature/pg is much larger — PgCrudRepository, projections, audit log, idempotency, rate limiter, columnar SQL, the migration runner. This crate ports the document-storage + locking core the framework itself needs, which is what the async and chat-bot addons sit on. The relational/columnar strategy and its migration tooling are a separate piece of work; nothing here forecloses it.

ⓘ
let db = PgDatabase::connect(PgConfig::from_env()?).await?;
c.register_instance::<PgDatabase>(Arc::new(db));

Re-exports§

pub use columns::PgColumnsStore;
pub use indexes::build_index_ddl;
pub use infra::PgAuditLog;
pub use infra::PgIdempotency;
pub use infra::PgRateLimiter;
pub use query_sql::build_query_sql;
pub use query_sql::BuiltQuery;
pub use query_sql::FieldPlacement;
pub use query_sql::QuerySqlError;
pub use config::PgConfig;
pub use error::PgError;
pub use error::PgResult;
pub use jsonb::PgJsonbStore;
pub use jsonb::PromotedColumn;
pub use locker::PgLocker;
pub use migrations::MigrationRunner;
pub use migrations::MigrationStatus;
pub use projection::PgProjectionRuntime;
pub use transaction::in_transaction;
pub use transaction::with_transaction;

Modules§

columns
Relational storage: every field is a real typed column. Port of PgColumnsRepository + pgColumnarSql in wabot-ts.
config
Pool construction + tuning. Port of pgPoolConfig.ts.
error
Error type shared by the pg feature and its addons.
indexes
Index declarations → Postgres DDL. Port of wabot-ts/src/feature/pg/pgIndexes.ts.
infra
Postgres-backed idempotency, rate limiting and audit log. Ports of PgIdempotency, PgRateLimiter and PgAuditLog.
jsonb
PgJsonbStore — Postgres document storage for entities.
locker
PgLocker — distributed Locker on Postgres advisory locks. Port of PgLocker.ts + PgLockKey.ts.
migrations
Plain-SQL migrations. Port of wabot-ts/src/feature/pg/migrations/MigrationRunner.ts.
projection
Postgres backend for projections. Port of wabot-ts/src/feature/pg/PgProjectionRuntime.ts.
query_sql
Turning a Query into SQL. Port of buildQuerySql.ts.
repository
PgJsonbStore as a CrudRepository.
transaction
Transactions. Port of withPgClient + withPgTransaction + PgTransactionAdapter in wabot-ts.

Structs§

PgDatabase
Owns the connection pool. A thin newtype rather than using sqlx::PgPool directly, because the DI container keys on the concrete type and a bare PgPool would collide with any other pool an app registers.