Class: Workhorse::Daemon::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/workhorse/daemon.rb

Overview

Internal representation of a worker process. Stores worker metadata and the block to execute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, &block) ⇒ Worker

Creates a new worker definition.

Parameters:

  • id (Integer)

    Unique identifier for this worker

  • name (String)

    Display name for this worker

  • block (Proc)

    Code block to execute in the worker process



26
27
28
29
30
# File 'lib/workhorse/daemon.rb', line 26

def initialize(id, name, &block)
  @id = id
  @name = name
  @block = block
end

Instance Attribute Details

#blockProc (readonly)

Returns The block containing the worker’s logic.

Returns:

  • (Proc)

    The block containing the worker’s logic



16
17
18
# File 'lib/workhorse/daemon.rb', line 16

def block
  @block
end

#idInteger (readonly)

Returns The worker’s unique ID.

Returns:

  • (Integer)

    The worker’s unique ID



10
11
12
# File 'lib/workhorse/daemon.rb', line 10

def id
  @id
end

#nameString (readonly)

Returns The worker’s display name.

Returns:

  • (String)

    The worker’s display name



13
14
15
# File 'lib/workhorse/daemon.rb', line 13

def name
  @name
end

#pidInteger?

Returns The worker’s process ID when running.

Returns:

  • (Integer, nil)

    The worker’s process ID when running



19
20
21
# File 'lib/workhorse/daemon.rb', line 19

def pid
  @pid
end