Async::Service::Supervisor::EnvoySourceAsyncServiceSupervisorEnvoyORCAService

class ORCAService

Streams per-worker out-of-band ORCA load reports to Envoy.

Definitions

def initialize(monitor, minimum_interval: 1)

Initialize the ORCA service.

Signature

parameter monitor Monitor

The monitor providing worker load reports.

parameter minimum_interval Numeric

The minimum reporting interval in seconds.

Implementation

def initialize(monitor, minimum_interval: 1)
	super(Xds::Service::Orca::V3::OpenRcaService, SERVICE_NAME)
	
	@monitor = monitor
	@minimum_interval = minimum_interval
end

def stream_core_metrics(input, output, call)

  • asynchronous

Stream current load reports for the worker named by the request authority.

Signature

parameter input Interface(:read)

The ORCA request stream.

parameter output Interface(:write)

The ORCA report stream.

parameter call Protocol::GRPC::Call

The gRPC call context.

asynchronous

Implementation

def stream_core_metrics(input, output, call)
	request = input.read
	return unless request
	
	authority = call.request.authority
	interval = [duration(request.report_interval), @minimum_interval].max
	
	while @monitor.worker?(authority)
		output.write(@monitor.load_report(authority) || EMPTY_REPORT)
		
		sleep(interval)
	end
rescue Protocol::HTTP::Body::Writable::Closed
	# The client closed the reporting stream.
end