lighthouse.discovery

class lighthouse.discovery.Discovery[source]

Bases: lighthouse.pluggable.Pluggable

Base class for discovery method plugins.

Unlike the Balancer base class for load balancer plugins, this discovery method plugin has several methods that subclasses are expected to define.

Subclasses are used for both the writer process and the reporter process so each subclass needs to be able to report on individual nodes as well as monitor and collect the status of all defined clusters.

It is important that the various instances of lighthouse running on various machines agree with each other on the status of clusters so a distributed system with strong CP characteristics is recommended.

config_subdirectory = 'discovery'
entry_point = 'lighthouse.discovery'
connect()[source]

Subclasses should define this method to handle any sort of connection establishment needed.

disconnect()[source]

This method is used to facilitate any shutting down operations needed by the subclass (e.g. closing connections and such).

start_watching(cluster, should_update)[source]

Method called whenever a new cluster is defined and must be monitored for changes to nodes.

Once a cluster is being successfully watched that cluster must be added to the self.watched_clusters set!

Whenever a change is detected, the given should_update threading event should be set.

stop_watching(cluster)[source]

This method should halt any of the monitoring started that would be started by a call to start_watching() with the same cluster.

Once the cluster is no longer being watched that cluster must be removed from the self.watched_clusters set!

report_up(service, port)[source]

This method is used to denote that the given service present on the current machine should be considered up and available.

report_down(service, port)[source]

This method is used to denote that the given service present on the current machine should be considered down and unavailable.

stop()[source]

Simple method that sets the shutdown event and calls the subclass’s wind_down() method.