PostgreSQL

Module pglift.postgresql exposes the following API to manipulate a PostgreSQL cluster:

async pglift.postgresql.status(instance: PostgreSQLInstance) Status

Return the status of an instance.

async pglift.postgresql.check_status(instance: PostgreSQLInstance, expected: Status) None

Check actual instance status with respected to expected one.

Raises:

InstanceStateError – in case the actual status is not expected.

async pglift.postgresql.is_ready(instance: PostgreSQLInstance) bool

Return True if the instance is ready per pg_isready.

pglift.postgresql.logs(instance: PostgreSQLInstance, *, timeout: float | None = None, poll_interval: float = 0.1) Iterator[str]

Return the content of current log file as an iterator.

async pglift.postgresql.replication_lag(instance: PostgreSQLInstance) Decimal | None

Return the replication lag of a standby instance.

The instance must be running; if the primary is not running, None is returned.

Raises:

TypeError – if the instance is not a standby.