module Supervised
An environment mixin for supervised worker services.
Enables workers to connect to and be supervised by the supervisor.
Definitions
def supervisor_ipc_path
The IPC path to use for communication with the supervisor.
Signature
-
returns
String
Implementation
def supervisor_ipc_path
::File.expand_path("supervisor.ipc", root)
end
def supervisor_endpoint
The endpoint the supervisor will bind to.
Signature
-
returns
::IO::Endpoint::Generic
Implementation
def supervisor_endpoint
::IO::Endpoint.unix(supervisor_ipc_path)
end
def supervisor_worker_state
The state to associate with the supervised worker.
Signature
-
returns
Hash
Implementation
def supervisor_worker_state
{name: self.name}
end
def supervisor_worker
The supervised worker for the current process.
Signature
-
returns
Worker The worker client.
Implementation
def supervisor_worker
Worker.new(process_id: Process.pid, endpoint: supervisor_endpoint, state: self.supervisor_worker_state)
end
def prepare!(instance)
Create a supervised worker for the given instance.
Signature
-
parameter
instanceAsync::Container::Instance The container instance.
-
returns
Worker The worker client.
Implementation
def prepare!(instance)
super(instance)
supervisor_worker.run
end