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
monitorMonitor The monitor providing worker load reports.
-
parameter
minimum_intervalNumeric 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
inputInterface(:read) The ORCA request stream.
-
parameter
outputInterface(:write) The ORCA report stream.
-
parameter
callProtocol::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