patroni.config module¶
- class patroni.config.Config(configfile: str, validator: ~typing.Optional[~typing.Callable[[~typing.Dict[str, ~typing.Any]], ~typing.List[str]]] = <function default_validator>)¶
Bases:
object
This class is responsible for:
Building and giving access to effective_configuration from: * Config.__DEFAULT_CONFIG – some sane default values * dynamic_configuration – configuration stored in DCS * local_configuration – configuration from config.yml or environment
Saving and loading dynamic_configuration into ‘patroni.dynamic.json’ file located in local_configuration[‘postgresql’][‘data_dir’] directory. This is necessary to be able to restore dynamic_configuration if DCS was accidentally wiped
Loading of configuration file in the old format and converting it into new format
Mimicking some of the dict interfaces to make it possible to work with it as with the old config object.
- PATRONI_CONFIG_VARIABLE = 'PATRONI_CONFIGURATION'¶
- get_global_config(cluster: Optional[Cluster]) GlobalConfig ¶
Instantiate
GlobalConfig
based on input.Use the configuration from provided cluster (the most up-to-date) or from the local cache if cluster.config is not initialized or doesn’t have a valid config. :param cluster: the currently known cluster state from DCS :returns:
GlobalConfig
object
- class patroni.config.GlobalConfig(config: Dict[str, Any])¶
Bases:
object
A class that wrapps global configuration and provides convinient methods to access/check values.
It is instantiated by calling
Config.global_config()
method which picks either a configuration from providedCluster
object (the most up-to-date) or from the local cache if :class::ClusterConfig is not initialized or doesn’t have a valid config.- check_mode(mode: str) bool ¶
Checks whether the certain parameter is enabled.
- Parameters:
mode – parameter name could be: synchronous_mode, failsafe_mode, pause, check_timeline, and so on
- Returns:
True if mode is enabled in the global configuration.
- get(name: str) Any ¶
Gets global configuration value by name.
- Parameters:
name – parameter name
- Returns:
configuration value or None if it is missing
- get_int(name: str, default: int = 0) int ¶
Gets current value from the global configuration and trying to return it as int.
- Parameters:
name – name of the parameter
default – default value if name is not in the configuration or invalid
- Returns:
currently configured value from the global configuration or default if it is not set or invalid.
- property is_standby_cluster: bool¶
True if global configuration has a valid “standby_cluster” section.
- Type:
returns
- property is_synchronous_mode_strict: bool¶
True if at least one synchronous node is required.
- Type:
returns
- property maximum_lag_on_failover: int¶
currently configured value from the global configuration or 1048576 if it is not set or invalid.
- Type:
returns
- property maximum_lag_on_syncnode: int¶
currently configured value from the global configuration or -1 if it is not set or invalid.
- Type:
returns
- property min_synchronous_nodes: int¶
the minimal number of synchronous nodes based on whether strict mode is requested or not.
- Type:
returns
- property primary_start_timeout: int¶
currently configured value from the global configuration or 300 if it is not set or invalid.
- Type:
returns
- patroni.config.get_global_config(cluster: Optional[Cluster], default: Optional[Dict[str, Any]] = None) GlobalConfig ¶
Instantiates
GlobalConfig
based on the input.- Parameters:
cluster – the currently known cluster state from DCS
default – default configuration, which will be used if there is no valid cluster.config
- Returns:
GlobalConfig
object