Class: RCelery::Worker
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Includes:
- Task::States
- Defined in:
- lib/rcelery/worker.rb
Constant Summary
Task::States::FAILURE, Task::States::RETRY, Task::States::SUCCESS
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Worker
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
|
#stop ⇒ Object
37
38
39
40
|
# File 'lib/rcelery/worker.rb', line 37
def stop
stop_heartbeat
RCelery::Events.worker_offline(@ident, @version, @system)
end
|
#subscribe ⇒ Object
31
32
33
34
35
|
# File 'lib/rcelery/worker.rb', line 31
def subscribe
loop do
consume @pool.poll
end
end
|