Class: BmcDaemonLib::WorkerBase

Inherits:
Object
  • Object
show all
Includes:
LoggerHelper
Defined in:
lib/bmc-daemon-lib/worker_base.rb

Instance Attribute Summary collapse

Attributes included from LoggerHelper

#logger

Instance Method Summary collapse

Constructor Details

#initialize(wid, pool = nil) ⇒ WorkerBase

Returns a new instance of WorkerBase.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bmc-daemon-lib/worker_base.rb', line 9

def initialize wid, pool = nil
  # Logger
  log_pipe :workers
  @log_worker_status_changes = true

  # Configuration
  @config = {}

  # Set thread context
  Thread.current.thread_variable_set :wid, (@wid = wid)
  Thread.current.thread_variable_set :pool, (@pool = pool)
  Thread.current.thread_variable_set :started_at, Time.now
  worker_status WORKER_STATUS_STARTING

  # Ask worker to init itself, and return if there are errors
  if worker_init_result = worker_init
    log_warn "aborting: #{worker_init_result.inspect}", @config
  else
    # We're ok, let's start out loop
    start_loop
  end
end

Instance Attribute Details

#poolObject (readonly)

Class options



6
7
8
# File 'lib/bmc-daemon-lib/worker_base.rb', line 6

def pool
  @pool
end

#widObject (readonly)

Returns the value of attribute wid.



7
8
9
# File 'lib/bmc-daemon-lib/worker_base.rb', line 7

def wid
  @wid
end