class Delegate
Maps supervisor controller state into Envoy endpoint records.
Definitions
def endpoints(supervisor_controller)
Extract endpoint state from the supervisor controller.
Signature
-
parameter
supervisor_controllerObject The supervisor controller describing the worker.
-
returns
Endpoint | Array(Endpoint) | Hash | Array(Hash) | Nil The endpoint state to publish.
Implementation
def endpoints(supervisor_controller)
state = supervisor_controller.state
state[:endpoints] || state["endpoints"] || state[:endpoint] || state["endpoint"]
end
def endpoint_list(supervisor_controller)
Convert endpoint state into endpoint values.
Signature
-
parameter
supervisor_controllerObject The supervisor controller describing the worker.
-
returns
Array(Endpoint) The 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)
state = supervisor_controller.state
endpoint.name || state[:name] || state["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