Async::Container::SupervisorSourceAsyncContainerSupervisorClient

class Client

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

Definitions

def connect

Connect to the server.

Implementation

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 run

Run the client in a loop, reconnecting if necessary.

Implementation

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