lighthouse.node

class lighthouse.node.Node(host, ip, port, peer=None, metadata=None)[source]

Bases: object

The class representing a member node of a cluster.

Consists of a port, a host and a peer, plus methods for serializing and deserializing themselves so that they can be transmitted back and forth via discovery methods.

name

Simple property for “naming” a node via the host and port.

classmethod current(service, port)[source]

Returns a Node instance representing the current service node.

Collects the host and IP information for the current machine and the port information from the given service.

serialize()[source]

Serializes the node data as a JSON map string.

classmethod deserialize(value)[source]

Creates a new Node instance via a JSON map string.

Note that port and ip and are required keys for the JSON map, peer and host are optional. If peer is not present, the new Node instance will use the current peer. If host is not present, the hostname of the given ip is looked up.