Skip to main content

Module pg

Module pg 

Source
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 through forge_runtime::pg” is enforced by layout, not just by convention.

Structs§

ChangeRow
One row of forge_change_log.
Database
Database connection wrapper with health-aware replica routing.
LeaderConfig
Leader election configuration.
LeaderElection
Leader election using PostgreSQL advisory locks.
NotifyChannel
Typed handle to a single PostgreSQL NOTIFY channel.
PgNotifyBus
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 NOTIFY payloads at 8000 bytes; we reserve ~1 KiB for PG framing, channel name, and the pg_notify SQL wrapper.

Functions§

drain_change_log
Stream every change with seq > since, in ascending seq order.
max_seq
Read the largest seq currently in the log, or None if it is empty.
min_seq
Read the smallest seq currently in the log, or None if it is empty.
trim_change_log
Delete every change-log row with created_at < before. Returns the number of rows deleted.