Async::Service::Supervisor::EnvoySourceAsyncServiceSupervisorEnvoyEndpointGroup

class EndpointGroup

Groups the workers reporting a single upstream endpoint.

Definitions

def initialize(endpoint)

Initialize an endpoint group.

Signature

parameter endpoint Endpoint

The endpoint shared by the workers.

Implementation

def initialize(endpoint)
	@endpoint = endpoint
	@workers = {}
end

attr :endpoint

Signature

attribute Endpoint

The endpoint shared by the workers.

def add(worker, healthy:)

Add or update a worker report.

Signature

parameter worker SupervisorController

The worker reporting the endpoint.

parameter healthy Boolean

Whether the worker considers the endpoint healthy.

Implementation

def add(worker, healthy:)
	@workers[worker.id] = healthy
end

def remove(worker)

Remove a worker report.

Signature

parameter worker SupervisorController

The worker to remove.

returns Boolean | Nil

The removed health value, if present.

Implementation

def remove(worker)
	@workers.delete(worker.id)
end

def size

Count the workers reporting this endpoint.

Signature

returns Integer

The number of reporting workers.

Implementation

def size
	@workers.size
end

def empty?

Determine whether any workers report this endpoint.

Signature

returns Boolean

Whether the group has no workers.

Implementation

def empty?
	@workers.empty?
end

def healthy?

Determine the aggregate endpoint health.

Signature

returns Boolean

Whether any reporting worker is healthy.

Implementation

def healthy?
	@workers.each_value.any?
end

def as_json

Convert the group to an xDS endpoint description.

Signature

returns Hash

The endpoint addresses and aggregate health.

Implementation

def as_json
	{addresses: @endpoint.addresses, healthy: healthy?}
end