Class: SimpleJob::Worker
Instance Method Summary
collapse
Methods inherited from Client
#bind, #exchange, #orig_send, #publish, #queue, #send, start, #subscribe
Instance Method Details
#handle(key, &proc) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/simplejob/worker.rb', line 26
def handle(key, &proc)
bind(@queue, key)
install_handler(key, proc)
end
|
#start(opts, &proc) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/simplejob/worker.rb', line 3
def start(opts, &proc)
super do
@channel.prefetch(1)
@queue = queue(opts[:queue_name] || "job_queue")
instance_exec(&proc)
start_handler_loop
log.info "[worker] Started"
end
end
|
#stop ⇒ Object
21
22
23
24
|
# File 'lib/simplejob/worker.rb', line 21
def stop
super
log.info "[worker] Stopped"
end
|