Async::Service::SupervisorSourceAsyncServiceSupervisorWorker

class Worker

A worker represents a long running process that can be controlled by the supervisor.

There are various tasks that can be executed by the worker, such as dumping memory, threads, and garbage collection profiles.

Definitions

def self.run(process_id: Process.pid, endpoint: Supervisor.endpoint)

Run a worker with the given process ID.

Signature

parameter process_id Integer

The process ID to register with the supervisor.

parameter endpoint IO::Endpoint

The supervisor endpoint to connect to.

Implementation

def self.run(process_id: Process.pid, endpoint: Supervisor.endpoint)
	self.new(process_id: process_id, endpoint: endpoint).run
end

def initialize(process_id: Process.pid, endpoint: Supervisor.endpoint, state: {})

Initialize a new worker.

Signature

parameter process_id Integer

The process ID to register with the supervisor.

parameter endpoint IO::Endpoint

The supervisor endpoint to connect to.

parameter state Hash

Optional state to associate with this worker (e.g., service name).

Implementation

def initialize(process_id: Process.pid, endpoint: Supervisor.endpoint, state: {})
	super(endpoint: endpoint)
	
	@id = nil
	@process_id = process_id
	@state = state
end

attr :id

Signature

attribute Integer

The ID assigned by the supervisor.

attr :process_id

Signature

attribute Integer

The process ID of the worker.

attr_accessor :state

Signature

attribute Hash

State associated with this worker (e.g., service name).