Class: Jobi::Job
- Inherits:
-
Object
show all
- Extended by:
- Utils
- Defined in:
- lib/jobi/job.rb
Class Method Summary
collapse
Methods included from Utils
constantize, generate_job_id
Class Method Details
.after_run(callback) ⇒ Object
17
18
19
|
# File 'lib/jobi/job.rb', line 17
def after_run(callback)
@after_run_callback = callback if callback
end
|
.consume_messages ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/jobi/job.rb', line 31
def consume_messages
return unless Jobi.consumer?
join_queue
@consumer_threads = []
@consumers.times do
@consumer_threads << Thread.new { consumer.consume! }
end
@consumer_threads.join(&:join)
end
|
.options(queue_name:, ack: false, consumers: 5, durable: true, persist: false) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/jobi/job.rb', line 9
def options(queue_name:, ack: false, consumers: 5, durable: true, persist: false)
@queue_name = queue_name.to_s
@ack = ack
@consumers = consumers
@durable = durable
@persist = persist
end
|
.run(**args) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/jobi/job.rb', line 21
def run(**args)
return unless Jobi.publisher?
before_start(args)
start
rescue Error => e
Jobi.logger.error('Failed to process the job')
Jobi.logger.error(e)
end
|