class Async::Container::Supervisor::Client

A client provides a mechanism to connect to a supervisor server in order to execute operations.

def connect

Connect to the server.
def connect
	connection = connect!
	connection.run_in_background(self)
	
	connected!(connection)
	
	return connection unless block_given?
	
	begin
		yield connection
	ensure
		connection.close
	end
end

def connect!

def connect!
ndpoint.connect
nnection.new(peer, 0)

def connected!(connection)

Called when a connection is established.
def connected!(connection)
ing by default.

def initialize(endpoint: Supervisor.endpoint)

def initialize(endpoint: Supervisor.endpoint)
	@endpoint = endpoint
end

def run

Run the client in a loop, reconnecting if necessary.
def run
	Async do
		loop do
			connection = connect!
			
			Async do
				connected!(connection)
			end
			
			connection.run(self)
		rescue => error
			Console.error(self, "Connection failed:", exception: error)
			sleep(rand)
		ensure
			connection&.close
		end
	end
end