Class: Async::Service::Supervisor::Envoy::EndpointGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/async/service/supervisor/envoy/endpoint_group.rb

Overview

Groups the workers reporting a single upstream endpoint.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#endpointObject (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_jsonObject

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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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

#sizeObject

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