patroni.postgresql.validator module¶
-
class
patroni.postgresql.validator.
Bool
(version_from: int, version_till: Optional[int] = None)¶ Bases:
patroni.postgresql.validator._Transformable
-
transform
(name: str, value: Any) → Optional[Any]¶ Verify that provided value is valid.
Parameters: - name – GUC’s name
- value – GUC’s value
Returns: the value (sometimes clamped) or
None
if the value isn’t valid
-
-
class
patroni.postgresql.validator.
Enum
(*, version_from: int, version_till: Optional[int] = None, possible_values: Tuple[str, ...])¶ Bases:
patroni.postgresql.validator._Transformable
-
possible_values
¶
-
transform
(name: str, value: Optional[Any]) → Optional[Any]¶ Verify that provided value is valid.
Parameters: - name – GUC’s name
- value – GUC’s value
Returns: the value (sometimes clamped) or
None
if the value isn’t valid
-
-
class
patroni.postgresql.validator.
EnumBool
(*, version_from: int, version_till: Optional[int] = None, possible_values: Tuple[str, ...])¶ Bases:
patroni.postgresql.validator.Enum
-
transform
(name: str, value: Optional[Any]) → Optional[Any]¶ Verify that provided value is valid.
Parameters: - name – GUC’s name
- value – GUC’s value
Returns: the value (sometimes clamped) or
None
if the value isn’t valid
-
-
class
patroni.postgresql.validator.
Integer
(*, version_from: int, version_till: Optional[int] = None, min_val: Union[int, float], max_val: Union[int, float], unit: Optional[str] = None)¶ Bases:
patroni.postgresql.validator.Number
-
static
parse
(value: Any, unit: Optional[str]) → Optional[int]¶ Convert provided value to unit.
-
static
-
exception
patroni.postgresql.validator.
InvalidGucValidatorsFile
(value: Any)¶ Bases:
patroni.exceptions.PatroniException
Raised when reading or parsing of a YAML file faces an issue.
-
class
patroni.postgresql.validator.
Number
(*, version_from: int, version_till: Optional[int] = None, min_val: Union[int, float], max_val: Union[int, float], unit: Optional[str] = None)¶ Bases:
patroni.postgresql.validator._Transformable
-
max_val
¶
-
min_val
¶
-
static
parse
(value: Any, unit: Optional[str]) → Optional[Any]¶ Convert provided value to unit.
-
transform
(name: str, value: Any) → Union[int, float, None]¶ Verify that provided value is valid.
Parameters: - name – GUC’s name
- value – GUC’s value
Returns: the value (sometimes clamped) or
None
if the value isn’t valid
-
unit
¶
-
-
class
patroni.postgresql.validator.
Real
(*, version_from: int, version_till: Optional[int] = None, min_val: Union[int, float], max_val: Union[int, float], unit: Optional[str] = None)¶ Bases:
patroni.postgresql.validator.Number
-
static
parse
(value: Any, unit: Optional[str]) → Optional[float]¶ Convert provided value to unit.
-
static
-
class
patroni.postgresql.validator.
String
(version_from: int, version_till: Optional[int] = None)¶ Bases:
patroni.postgresql.validator._Transformable
-
transform
(name: str, value: Optional[Any]) → Optional[Any]¶ Verify that provided value is valid.
Parameters: - name – GUC’s name
- value – GUC’s value
Returns: the value (sometimes clamped) or
None
if the value isn’t valid
-
-
class
patroni.postgresql.validator.
ValidatorFactory
¶ Bases:
object
Factory class used to build Patroni validator objects based on the given specs.
-
TYPES
= {'Bool': <class 'patroni.postgresql.validator.Bool'>, 'Enum': <class 'patroni.postgresql.validator.Enum'>, 'EnumBool': <class 'patroni.postgresql.validator.EnumBool'>, 'Integer': <class 'patroni.postgresql.validator.Integer'>, 'Number': <class 'patroni.postgresql.validator.Number'>, 'Real': <class 'patroni.postgresql.validator.Real'>, 'String': <class 'patroni.postgresql.validator.String'>}¶
-
-
exception
patroni.postgresql.validator.
ValidatorFactoryInvalidSpec
(value: Any)¶ Bases:
patroni.exceptions.PatroniException
Raised when a validator spec contains an invalid set of attributes.
-
exception
patroni.postgresql.validator.
ValidatorFactoryInvalidType
(value: Any)¶ Bases:
patroni.exceptions.PatroniException
Raised when a validator spec contains an invalid type.
-
exception
patroni.postgresql.validator.
ValidatorFactoryNoType
(value: Any)¶ Bases:
patroni.exceptions.PatroniException
Raised when a validator spec misses a type.
-
patroni.postgresql.validator.
transform_postgresql_parameter_value
(version: int, name: str, value: Any, available_gucs: patroni.collections.CaseInsensitiveSet) → Optional[Any]¶ Validate value of GUC name for Postgres version using
parameters
and available_gucs.Parameters: - version – Postgres version to validate the GUC against.
- name – name of the Postgres GUC.
- value – value of the Postgres GUC.
- available_gucs –
a set of all GUCs available in Postgres version. Each item is the name of a Postgres GUC. Used for a couple purposes:
- Disallow writing GUCs to
postgresql.conf
that does not exist in Postgres version; - Avoid ignoring GUC name if it does not have a validator in
parameters
, but is a valid GUC in - Postgres version.
- Avoid ignoring GUC name if it does not have a validator in
- Disallow writing GUCs to
Returns: The return value may be one among:
- The original value if name seems to be an extension GUC (contains a period ‘.’); or
None
if name is a recovery GUC; or- value transformed to the expected format for GUC name in Postgres version using validators defined in
parameters
. Can also returnNone
. See_transform_parameter_value()
.
-
patroni.postgresql.validator.
transform_recovery_parameter_value
(version: int, name: str, value: Any, available_gucs: patroni.collections.CaseInsensitiveSet) → Optional[Any]¶ Validate value of GUC name for Postgres version using
recovery_parameters
and available_gucs.Parameters: - version – Postgres version to validate the recovery GUC against.
- name – name of the Postgres recovery GUC.
- value – value of the Postgres recovery GUC.
- available_gucs –
a set of all GUCs available in Postgres version. Each item is the name of a Postgres GUC. Used for a couple purposes:
- Disallow writing GUCs to
recovery.conf
(orpostgresql.conf
depending on version), that does not - exist in Postgres version;
- Disallow writing GUCs to
- Avoid ignoring recovery GUC name if it does not have a validator in
recovery_parameters
, but is a - valid GUC in Postgres version.
- Avoid ignoring recovery GUC name if it does not have a validator in
Returns: value transformed to the expected format for recovery GUC name in Postgres version using validators defined in
recovery_parameters
. It can also returnNone
. See_transform_parameter_value()
.