patroni package

Module contents

Define general variables and functions for patroni.

var PATRONI_ENV_PREFIX:
 prefix for Patroni related configuration environment variables.
var KUBERNETES_ENV_PREFIX:
 prefix for Kubernetes related configuration environment variables.
var MIN_PSYCOPG2:
 minimum version of psycopg2 required by Patroni to work.
patroni.check_psycopg(_min_psycopg2: Tuple[int, ...] = (2, 5, 4), _parse_version: Callable[[str], Tuple[int, ...]] = <function parse_version>) → None

Ensure at least one among psycopg2 or psycopg libraries are available in the environment.

Note

We pass MIN_PSYCOPG2 and parse_version() as arguments to simplify usage of check_psycopg() from the setup.py.

Note

Patroni chooses psycopg2 over psycopg, if possible.

If nothing meeting the requirements is found, then exit with a fatal message.

Parameters:
  • _min_psycopg2 – minimum required version in case psycopg2 is chosen.
  • _parse_version – function used to parse psycopg2/psycopg version into a comparable object.
patroni.fatal(string: str, *args) → None

Write a fatal message to stderr and exit with code 1.

Parameters:string – message to be written before exiting.
patroni.parse_version(version: str) → Tuple[int, ...]

Convert version from human-readable format to tuple of integers.

Note

Designed for easy comparison of software versions in Python.

Parameters:

version – human-readable software version, e.g. 2.5.4.

Returns:

tuple of version parts, each part as an integer.

Example:
>>> parse_version('2.5.4')
(2, 5, 4)