Integration with Synapse’s
file_output service discovery method.
Production Baseplate services have Synapse hooked up to a local HAProxy instance which will automatically route connections to services for you if you connect to the correct address/port on localhost. That is the preferred method of connecting to services.
The contents of this module are useful for inspecting the service inventory directly for cases where a blind TCP connection is insufficient (e.g. to give service addresses to a client, or for topology-aware clients like Cassandra).
A basic example of usage:
inventory = ServiceInventory("/var/lib/synapse/example.json") backend = inventory.get_backend() print(backend.endpoint.address)
The inventory enumerates available backends for a single service.
str) – The absolute path to the Synapse-generated inventory file in JSON format.
Return a list of all available backends in the inventory.
If the inventory file becomes unavailable, the previously seen inventory is returned.
Backend(id: int, name: str, endpoint: baseplate.lib.config.EndpointConfiguration, weight: int)¶
A description of a service backend.
This is a tuple of several values:
A unique integer ID identifying the backend.
The name of the backend.
EndpointConfigurationobject describing the network address of the backend.
An integer weight indicating how much to prefer this backend when choosing whom to connect to.