class Delegate
Maps supervisor state into Envoy upstream endpoints.
Definitions
def endpoints(supervisor_controller)
Extract serialized endpoints from a supervisor controller.
Signature
-
parameter
supervisor_controllerObject The supervisor controller describing the worker.
-
returns
Hash | Array(Hash) | Nil The serialized endpoint state.
Implementation
def endpoints(supervisor_controller)
state = supervisor_controller.state
state[:endpoints] || state[:endpoint]
end
def endpoint_list(supervisor_controller)
Convert serialized state into Envoy endpoint values.
Signature
-
parameter
supervisor_controllerObject The supervisor controller describing the worker.
-
returns
Array(Endpoint) The upstream endpoints to publish.
Implementation
def endpoint_list(supervisor_controller)
case endpoints = self.endpoints(supervisor_controller)
when nil
[]
when Array
endpoints.map{|endpoint| Endpoint.wrap(endpoint)}
else
[Endpoint.wrap(endpoints)]
end
end
def cluster(supervisor_controller, endpoint)
Select the Envoy cluster name for an endpoint.
Signature
-
parameter
supervisor_controllerObject The supervisor controller describing the worker.
-
parameter
endpointEndpoint The endpoint being published.
-
returns
String | Nil The cluster name, or nil to skip the endpoint.
Implementation
def cluster(supervisor_controller, endpoint)
endpoint.name
end
def healthy?(supervisor_controller, endpoint)
Determine whether an endpoint should be published as healthy.
Signature
-
parameter
supervisor_controllerObject The supervisor controller describing the worker.
-
parameter
endpointEndpoint The endpoint being published.
-
returns
Boolean Whether the endpoint is healthy.
Implementation
def healthy?(supervisor_controller, endpoint)
true
end