Class: Wamp::Worker::Runner::Background
- Defined in:
- lib/wamp/worker/runner.rb
Overview
This class monitors the queue and returns the descriptor
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Attributes inherited from Base
Instance Method Summary collapse
-
#_start ⇒ Object
Starts the background runner.
-
#initialize(name, uuid: nil, &callback) ⇒ Background
constructor
Constructor.
Methods inherited from Base
#_stop, #active?, #logger, #start, #stop
Constructor Details
#initialize(name, uuid: nil, &callback) ⇒ Background
Constructor
67 68 69 70 71 72 73 74 |
# File 'lib/wamp/worker/runner.rb', line 67 def initialize(name, uuid: nil, &callback) super name, uuid: uuid @callback = callback # Log the event logger.debug("#{self.class.name} '#{self.name}' created") end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
62 63 64 |
# File 'lib/wamp/worker/runner.rb', line 62 def callback @callback end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
62 63 64 |
# File 'lib/wamp/worker/runner.rb', line 62 def thread @thread end |
Instance Method Details
#_start ⇒ Object
Starts the background runner
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/wamp/worker/runner.rb', line 78 def _start # Start the background thread Thread.new do # The background thread will infinitely call the callback while the # runner is active while self.active? begin self.callback.call(self) rescue => e logger.error("#{self.class.name} #{e.class.name} - #{e.}") end end end end |