Class: Mettric::Worker
- Inherits:
-
Object
- Object
- Mettric::Worker
- Defined in:
- lib/mettric/worker.rb
Instance Method Summary collapse
-
#initialize(queue, config = Mettric.config) ⇒ Worker
constructor
A new instance of Worker.
- #loop ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
Instance Method Details
#loop ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mettric/worker.rb', line 16 def loop Mettric::Client.new(@config) do |client| deliver(client, service: 'mettric.worker.start', metric: 1) rescue nil while payload = @queue.pop deliver(client, payload) end end end |
#start ⇒ Object
9 10 11 12 13 14 |
# File 'lib/mettric/worker.rb', line 9 def start return false if @started puts "Mettric::Worker#start" if @config[:debug] @started = true loop end |
#stop ⇒ Object
25 26 27 28 |
# File 'lib/mettric/worker.rb', line 25 def stop puts "Mettric::Worker#stop" if @config[:debug] @started = false end |