lighthouse.check

class lighthouse.check.Check[source]

Bases: lighthouse.pluggable.Pluggable

Base class for service check plugins.

Subclasses are expected to define a name for the check, plus methods for validating that any dependencies are present, the given config is valid, and of course performing the check itself.

entry_point = 'lighthouse.checks'
classmethod validate_check_config(config)[source]

This method should return True if the given config is valid for the health check subclass, False otherwise.

apply_check_config(config)[source]

This method takes an already-validated configuration dictionary as its only argument.

The method should set any attributes or state in the instance needed for performing the health check.

perform()[source]

This perform() is at the heart of the check. Subclasses must define this method to actually perform their check. If the check passes, the method should return True, otherwise False.

Note that this method takes no arguments. Any sort of context required for performing a check should be handled by the config.

run()[source]

Calls the perform() method defined by subclasses and stores the result in a results deque.

After the result is determined the results deque is analyzed to see if the passing flag should be updated. If the check was considered passing and the previous self.fall number of checks failed, the check is updated to not be passing. If the check was not passing and the previous self.rise number of checks passed, the check is updated to be considered passing.

last_n_results(n)[source]

Helper method for returning a set number of the previous check results.

apply_config(config)[source]

Sets attributes based on the given config.

Also adjusts the results deque to either expand (padding itself with False results) or contract (by removing the oldest results) until it matches the required length.

classmethod validate_config(config)[source]

Validates that required config entries are present.

Each check requires a host, port, rise and fall to be configured.

The rise and fall variables are integers denoting how many times a check must pass before being considered passing and how many times a check must fail before being considered failing.

class lighthouse.check.deque(iterable=(), maxlen=None)[source]

Bases: collections.deque

Custom collections.deque subclass for 2.6 compatibility.

The python 2.6 version of the deque class doesn’t support referring to the maxlen attribute.

maxlen