Class: Hawkei::Processor::Worker
- Inherits:
-
Object
- Object
- Hawkei::Processor::Worker
- Defined in:
- lib/hawkei/processor/worker.rb
Constant Summary collapse
- FLUSH_INTERVAL_SECONDS =
3
- FLUSH_MESSAGE =
Object.new
- SHUTDOWN_MESSAGE =
Object.new
Instance Method Summary collapse
-
#initialize(queue, state) ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
Constructor Details
#initialize(queue, state) ⇒ Worker
Returns a new instance of Worker.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hawkei/processor/worker.rb', line 10 def initialize(queue, state) @queue = queue @state = state @batch = Batch.new @promises = Concurrent::Array.new @timer = Concurrent::TimerTask.new(execution_interval: FLUSH_INTERVAL_SECONDS) { @queue << FLUSH_MESSAGE } @timer.execute end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/hawkei/processor/worker.rb', line 21 def run while thread_active? = @queue.pop () end shutdown_worker end |