Class: RCelery::Worker

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Task::States
Defined in:
lib/rcelery/worker.rb

Constant Summary

Constants included from Task::States

Task::States::FAILURE, Task::States::RETRY, Task::States::SUCCESS

Instance Method Summary collapse

Constructor Details

#initializeWorker

Returns a new instance of Worker.



15
16
17
18
19
20
21
22
# File 'lib/rcelery/worker.rb', line 15

def initialize
  @heartbeat = 60
  @poll_interval = 0.5

  @ident = 'rcelery'
  @version  = RCelery::VERSION
  @system = RUBY_PLATFORM
end

Instance Method Details

#start(pool) ⇒ Object



24
25
26
27
28
29
# File 'lib/rcelery/worker.rb', line 24

def start(pool)
  RCelery::Events.worker_online(@ident, @version, @system)
  @pool = pool
  start_heartbeat
  subscribe
end

#stopObject



37
38
39
40
# File 'lib/rcelery/worker.rb', line 37

def stop
  stop_heartbeat
  RCelery::Events.worker_offline(@ident, @version, @system)
end

#subscribeObject



31
32
33
34
35
# File 'lib/rcelery/worker.rb', line 31

def subscribe
  loop do
    consume @pool.poll
  end
end