Expand description
PostgreSQL primitives: pooling, leader election, migrations, NOTIFY.
Re-exports§
pub use migration::AppliedMigration;pub use migration::DriftStatus;pub use migration::Migration;pub use migration::MigrationRunner;pub use migration::MigrationStatus;pub use migration::load_migrations_from_dir;
Modules§
- migration
- Database migration system. Lives under
pg/with the rest of the Postgres primitives so the doctrine “all PG-touching code goes throughforge_runtime::pg” is enforced by layout, not just by convention.
Structs§
- Change
Row - One row of
forge_change_log. - Database
- Database connection wrapper with health-aware replica routing.
- Leader
Config - Leader election configuration.
- Leader
Election - Leader election using PostgreSQL advisory locks.
- Notify
Channel - Typed handle to a single PostgreSQL
NOTIFYchannel. - PgNotify
Bus - Process-wide PostgreSQL LISTEN multiplexer.
Constants§
- LEADER_
RELEASED_ CHANNEL - PG NOTIFY channel pinged when a leader voluntarily releases its slot. Payload is the role string; subscribers filter by their own role.
- MAX_
PAYLOAD_ BYTES - Maximum serialized JSON payload bytes. PostgreSQL caps
NOTIFYpayloads at 8000 bytes; we reserve ~1 KiB for PG framing, channel name, and thepg_notifySQL wrapper.
Functions§
- drain_
change_ log - Stream every change with
seq > since, in ascendingseqorder. - max_seq
- Read the largest
seqcurrently in the log, orNoneif it is empty. - min_seq
- Read the smallest
seqcurrently in the log, orNoneif it is empty. - trim_
change_ log - Delete every change-log row with
created_at < before. Returns the number of rows deleted.