Module: Async::Service::Supervisor::Envoy::Supervised

Includes:
Supervised
Defined in:
lib/async/service/supervisor/envoy/supervised.rb

Overview

Registers post-bind cluster listeners with the supervisor.

Instance Method Summary collapse

Instance Method Details

#envoy_address(address) ⇒ Object

Convert a concrete bound address to serializable supervisor state.



39
40
41
42
43
44
45
46
47
# File 'lib/async/service/supervisor/envoy/supervised.rb', line 39

def envoy_address(address)
	if address.ip?
		{address: address.ip_address, port: address.ip_port}
	elsif address.unix?
		{path: address.unix_path}
	else
		raise ArgumentError, "Unsupported listener address: #{address.inspect}"
	end
end

#envoy_endpoint(listener) ⇒ Object

Convert a bound listener into serialized Envoy endpoint state.



26
27
28
29
30
31
32
33
# File 'lib/async/service/supervisor/envoy/supervised.rb', line 26

def envoy_endpoint(listener)
	{
		name: listener.name,
		scheme: listener.scheme,
		protocols: listener.protocols,
		addresses: listener.addresses.map{|address| envoy_address(address)},
	}
end

#prepare_worker!(instance, listener:) ⇒ Object

Prepare and register a worker after its listener has been bound.



19
20
21
# File 'lib/async/service/supervisor/envoy/supervised.rb', line 19

def prepare_worker!(instance, listener:)
	prepare!(instance, state: {endpoint: envoy_endpoint(listener)})
end