Class: QPush::Server::Worker
- Inherits:
-
Object
- Object
- QPush::Server::Worker
- Defined in:
- lib/qpush/server/worker.rb
Overview
The Worker manages our actions - Queue, Delay, Perform and Heartbeat. Each of these actions is alloted a number of threads. Each action object maintains control of these threads through the aptly named start and shutdown methods.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(id, config) ⇒ 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(id, config) ⇒ Worker
Returns a new instance of Worker.
24 25 26 27 28 29 30 31 |
# File 'lib/qpush/server/worker.rb', line 24 def initialize(id, config) @id = id @pid = Process.pid @config = config @actions = [] @threads = [] at_exit { shutdown } end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/qpush/server/worker.rb', line 22 def config @config end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/qpush/server/worker.rb', line 22 def id @id end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
22 23 24 |
# File 'lib/qpush/server/worker.rb', line 22 def pid @pid end |
Instance Method Details
#shutdown ⇒ Object
Shutsdown our worker as well as its threads.
45 46 47 48 49 |
# File 'lib/qpush/server/worker.rb', line 45 def shutdown @actions.each(&:shutdown) @threads.each(&:exit) end |
#start ⇒ Object
Starts our new worker.
35 36 37 38 39 40 41 |
# File 'lib/qpush/server/worker.rb', line 35 def start assign_globals register_space build_actions start_threads end |