Sha256: ae118efc491b1461a43a3e0204409c5fb8f43aff8f6c0816324aa1270a6d35b0

Contents?: true

Size: 987 Bytes

Versions: 31

Compression:

Stored size: 987 Bytes

Contents

module Shoryuken
  module Worker
    class DefaultExecutor
      class << self
        def perform_async(worker_class, body, options = {})
          options[:message_attributes] ||= {}
          options[:message_attributes]['shoryuken_class'] = {
            string_value: worker_class.to_s,
            data_type: 'String'
          }

          options[:message_body] = body

          queue = options.delete(:queue) || worker_class.get_shoryuken_options['queue']

          Shoryuken::Client.queues(queue).send_message(options)
        end

        def perform_in(worker_class, interval, body, options = {})
          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, options.merge(delay_seconds: delay))
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
shoryuken-6.2.1 lib/shoryuken/worker/default_executor.rb
shoryuken-6.2.0 lib/shoryuken/worker/default_executor.rb
shoryuken-6.1.1 lib/shoryuken/worker/default_executor.rb
shoryuken-6.1.0 lib/shoryuken/worker/default_executor.rb
shoryuken-6.0.0 lib/shoryuken/worker/default_executor.rb
shoryuken-5.3.2 lib/shoryuken/worker/default_executor.rb
shoryuken-5.3.1 lib/shoryuken/worker/default_executor.rb
shoryuken-5.3.0 lib/shoryuken/worker/default_executor.rb
shoryuken-5.2.3 lib/shoryuken/worker/default_executor.rb
shoryuken-5.2.2 lib/shoryuken/worker/default_executor.rb
shoryuken-5.2.1 lib/shoryuken/worker/default_executor.rb
shoryuken-5.2.0 lib/shoryuken/worker/default_executor.rb
shoryuken-5.1.1 lib/shoryuken/worker/default_executor.rb
shoryuken-5.1.0 lib/shoryuken/worker/default_executor.rb
shoryuken-5.0.6 lib/shoryuken/worker/default_executor.rb
shoryuken-5.0.5 lib/shoryuken/worker/default_executor.rb
shoryuken-5.0.4 lib/shoryuken/worker/default_executor.rb
shoryuken-5.0.3 lib/shoryuken/worker/default_executor.rb
shoryuken-5.0.2 lib/shoryuken/worker/default_executor.rb
shoryuken-5.0.1 lib/shoryuken/worker/default_executor.rb