Class: ActiveHook::Server::Worker
- Inherits:
-
Object
- Object
- ActiveHook::Server::Worker
- Defined in:
- lib/activehook/server/worker.rb
Overview
The Worker manages our two main processes - Queue and Retry. Each of these processes is alloted a number of threads. These threads are then forked. Each worker object maintains control of these threads through the aptly named start and shutdown methods.
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#queue_threads ⇒ Object
Returns the value of attribute queue_threads.
-
#retry_threads ⇒ Object
Returns the value of attribute retry_threads.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Worker
constructor
A new instance of Worker.
-
#shutdown ⇒ Object
Shutsdown our worker as well as its threads.
-
#start ⇒ Object
Starts our new worker.
Constructor Details
#initialize(options = {}) ⇒ Worker
11 12 13 14 15 16 17 |
# File 'lib/activehook/server/worker.rb', line 11 def initialize( = {}) .each { |key, value| send("#{key}=", value) } @pid = Process.pid @threads = [] @_threads_real = [] at_exit { shutdown } end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/activehook/server/worker.rb', line 9 def id @id end |
#queue_threads ⇒ Object
Returns the value of attribute queue_threads.
9 10 11 |
# File 'lib/activehook/server/worker.rb', line 9 def queue_threads @queue_threads end |
#retry_threads ⇒ Object
Returns the value of attribute retry_threads.
9 10 11 |
# File 'lib/activehook/server/worker.rb', line 9 def retry_threads @retry_threads end |
Instance Method Details
#shutdown ⇒ Object
Shutsdown our worker as well as its threads.
30 31 32 33 34 |
# File 'lib/activehook/server/worker.rb', line 30 def shutdown @threads.each(&:shutdown) @_threads_real.each(&:exit) end |
#start ⇒ Object
Starts our new worker.
21 22 23 24 25 26 |
# File 'lib/activehook/server/worker.rb', line 21 def start validate! build_threads start_threads end |