module Supervised
Registers post-bind cluster listeners with the supervisor.
Definitions
def prepare_worker!(instance, listener:)
Prepare and register a worker after its listener has been bound.
Signature
-
parameter
instanceAsync::Container::Instance The container instance.
-
parameter
listenerObject The bound listener descriptor.
Implementation
def prepare_worker!(instance, listener:)
prepare!(instance, state: {endpoint: envoy_endpoint(listener)})
end
def envoy_endpoint(listener)
Convert a bound listener into serialized Envoy endpoint state.
Signature
-
parameter
listenerObject The bound listener descriptor.
-
returns
Hash The serialized endpoint.
Implementation
def envoy_endpoint(listener)
{
name: listener.name,
scheme: listener.scheme,
protocols: listener.protocols,
addresses: listener.addresses.map{|address| envoy_address(address)},
}
end
def envoy_address(address)
Convert a concrete bound address to serializable supervisor state.
Signature
-
parameter
addressAddrinfo The bound address.
-
returns
Hash The serialized address.
-
raises
ArgumentError If the address family is unsupported.
Implementation
def envoy_address(address)
if address.ip?
{address: address.ip_address, port: address.ip_port}
elsif address.unix?
{path: address.unix_path}
else
raise ArgumentError, "Unsupported listener address: #{address.inspect}"
end
end