Sha256: aaf8376947b49c264ba353dc5c22f4725502c78bc0c83fec1bdc5ca69052b030

Contents?: true

Size: 1.12 KB

Versions: 24

Compression:

Stored size: 1.12 KB

Contents

module Shoryuken
  module Worker
    class InlineExecutor
      class << self
        def perform_async(worker_class, body, options = {})
          body = JSON.dump(body) if body.is_a?(Hash)
          queue_name = options.delete(:queue) || worker_class.get_shoryuken_options['queue']

          sqs_msg = OpenStruct.new(
            body: body,
            attributes: nil,
            md5_of_body: nil,
            md5_of_message_attributes: nil,
            message_attributes: nil,
            message_id: nil,
            receipt_handle: nil,
            delete: nil,
            queue_name: queue_name
          )

          call(worker_class, sqs_msg)
        end

        def perform_in(worker_class, _interval, body, options = {})
          worker_class.perform_async(body, options)
        end

        private

        def call(worker_class, sqs_msg)
          parsed_body = BodyParser.parse(worker_class, sqs_msg)
          batch = worker_class.shoryuken_options_hash['batch']
          args = batch ? [[sqs_msg], [parsed_body]] : [sqs_msg, parsed_body]
          worker_class.new.perform(*args)
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

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