Class: Shoryuken::Worker::DefaultExecutor
- Inherits:
-
Object
- Object
- Shoryuken::Worker::DefaultExecutor
- Defined in:
- lib/shoryuken/worker/default_executor.rb
Class Method Summary collapse
- .perform_async(worker_class, body, options = {}) ⇒ Object
- .perform_in(worker_class, interval, body, options = {}) ⇒ Object
Class Method Details
.perform_async(worker_class, body, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/shoryuken/worker/default_executor.rb', line 5 def perform_async(worker_class, body, = {}) [:message_attributes] ||= {} [:message_attributes]['shoryuken_class'] = { string_value: worker_class.to_s, data_type: 'String' } [:message_body] = body queue = .delete(:queue) || worker_class.['queue'] Shoryuken::Client.queues(queue).() end |
.perform_in(worker_class, interval, body, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/shoryuken/worker/default_executor.rb', line 19 def perform_in(worker_class, interval, body, = {}) interval = interval.to_f now = Time.now.to_f ts = (interval < 1_000_000_000 ? (now + interval).to_f : interval) delay = (ts - now).ceil raise 'The maximum allowed delay is 15 minutes' if delay > 15 * 60 worker_class.perform_async(body, .merge(delay_seconds: delay)) end |