Skip to content

Commit

Permalink
Add rudimentary docstrings to some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jankatins committed Sep 14, 2021
1 parent d68bc1f commit b47815d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pglookout/cluster_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def wait_select(conn, timeout=5.0):
class ClusterMonitor(Thread):
def __init__(self, config, cluster_state, observer_state, create_alert_file, cluster_monitor_check_queue,
failover_decision_queue, is_replication_lag_over_warning_limit, stats):
"""Thread which collects cluster state.
Basically a loop which tries to connect to each cluster member and
to external observers for status information. The information is collected
in the cluster_state/observer_state dictionaries, which are shared with the main thread.
"""
Thread.__init__(self)
self.log = logging.getLogger("ClusterMonitor")
self.stats = stats
Expand Down
9 changes: 8 additions & 1 deletion pglookout/pglookout.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ def load_config(self, _signal=None, _frame=None):
self.cluster_monitor_check_queue.put("new config came, recheck")

def write_cluster_state_to_json_file(self):
"""Periodically write a JSON state file to disk"""
"""Periodically write a JSON state file to disk
Currently only used to share state with the current_master helper command, pglookout itself does
not rely in this file.
"""
start_time = time.monotonic()
state_file_path = self.config.get("json_state_file_path", "/tmp/pglookout_state.json")
try:
Expand All @@ -183,6 +187,9 @@ def write_cluster_state_to_json_file(self):
self.stats.unexpected_exception(ex, where="write_cluster_state_to_json_file")

def create_node_map(self, cluster_state, observer_state):
"""Computes roles for each known member of cluster.
Use the information gathered in the cluster_state and observer_state to figure out the roles of each member."""
standby_nodes, master_node, master_instance = {}, None, None
connected_master_nodes, disconnected_master_nodes = {}, {}
connected_observer_nodes, disconnected_observer_nodes = {}, {}
Expand Down

0 comments on commit b47815d

Please sign in to comment.