Class: Async::Service::Supervisor::Envoy::EndpointGroup
- Inherits:
-
Object
- Object
- Async::Service::Supervisor::Envoy::EndpointGroup
- Defined in:
- lib/async/service/supervisor/envoy/endpoint_group.rb
Overview
Groups the workers reporting a single upstream endpoint.
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#add(worker, healthy:) ⇒ Object
Add or update a worker report.
-
#as_json ⇒ Object
Convert the group to an xDS endpoint description.
-
#empty? ⇒ Boolean
Determine whether any workers report this endpoint.
-
#healthy? ⇒ Boolean
Determine the aggregate endpoint health.
-
#initialize(endpoint) ⇒ EndpointGroup
constructor
Initialize an endpoint group.
-
#remove(worker) ⇒ Object
Remove a worker report.
-
#size ⇒ Object
Count the workers reporting this endpoint.
- #The endpoint shared by the workers.=(endpointsharedbytheworkers. = (value)) ⇒ Object
Constructor Details
#initialize(endpoint) ⇒ EndpointGroup
Initialize an endpoint group.
14 15 16 17 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 14 def initialize(endpoint) @endpoint = endpoint @workers = {} end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
20 21 22 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 20 def endpoint @endpoint end |
Instance Method Details
#add(worker, healthy:) ⇒ Object
Add or update a worker report.
25 26 27 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 25 def add(worker, healthy:) @workers[worker.id] = healthy end |
#as_json ⇒ Object
Convert the group to an xDS endpoint description.
56 57 58 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 56 def as_json {addresses: @endpoint.addresses, healthy: healthy?} end |
#empty? ⇒ Boolean
Determine whether any workers report this endpoint.
44 45 46 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 44 def empty? @workers.empty? end |
#healthy? ⇒ Boolean
Determine the aggregate endpoint health.
50 51 52 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 50 def healthy? @workers.each_value.any? end |
#remove(worker) ⇒ Object
Remove a worker report.
32 33 34 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 32 def remove(worker) @workers.delete(worker.id) end |
#size ⇒ Object
Count the workers reporting this endpoint.
38 39 40 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 38 def size @workers.size end |
#The endpoint shared by the workers.=(endpointsharedbytheworkers. = (value)) ⇒ Object
20 |
# File 'lib/async/service/supervisor/envoy/endpoint_group.rb', line 20 attr :endpoint |