patroni.tags module
Tags handling.
- class patroni.tags.Tags
Bases:
ABCAn abstract class that encapsulates all the
tagslogic.Child classes that want to use provided facilities must implement
tagsabstract property.Note
Due to backward-compatibility reasons, old tags may have a less strict type conversion than new ones.
- _abc_impl = <_abc._abc_data object>
- _bool_tag(bool_name: str, priority_name: str) → bool
Common logic for obtaining the value of a boolean tag from
tagsif defined.If boolean tag is not defined, this methods returns
Trueif priority tag is non-positive,Falseotherwise.- Parameters:
bool_name – name of the boolean tag (
nofailover.nosync).priority_name – name of the priority tag (
failover_priority,sync_priority).
- Returns:
boolean value based on the defined tags.
- static _filter_tags(tags: Dict[str, Any]) → Dict[str, Any]
Get tags configured for this node, if any.
Handle both predefined Patroni tags and custom defined tags.
Note
A custom tag is any tag added to the configuration
tagssection that is not one ofclonefrom,nofailover,noloadbalance,``nosync`` ornostream.For most of the Patroni predefined tags, the returning object will only contain them if they are enabled as they all are boolean values that default to disabled. However
nofailovertag is always returned iffailover_prioritytag is defined. In this case, we need both values to see if they are contradictory and thenofailovervalue should be used. The same rule applies fornosyncandsync_prioritytags.- Returns:
a dictionary of tags set for this node. The key is the tag name, and the value is the corresponding tag value.
- _priority_tag(bool_name: str, priority_name: str) → int
Common logic for obtaining the value of a priority tag from
tagsif defined.If boolean tag is defined as
True, this will return0. Otherwise, it will return the value of the respective priority tag, defaulting to1if it’s not defined or invalid.- Parameters:
bool_name – name of the boolean tag (
nofailover.nosync).priority_name – name of the priority tag (
failover_priority,sync_priority).
- Returns:
integer value based on the defined tags.
- property failover_priority: int
Value of
failover_priorityfromtagsif defined, otherwise derived fromnofailover.
- property nofailover: bool
Trueif node configuration doesn’t allow it to become primary,Falseotherwise.
- property nosync: bool
Trueif node configuration doesn’t allow it to become synchronous,Falseotherwise.