Module: Shoryuken::Worker

Included in:
ActiveJob::QueueAdapters::ShoryukenAdapter::JobWrapper
Defined in:
lib/shoryuken/worker.rb,
lib/shoryuken/worker/inline_executor.rb,
lib/shoryuken/worker/default_executor.rb

Overview

Worker module provides the core functionality for creating Shoryuken workers that process messages from Amazon SQS queues.

Including this module in a class provides methods for configuring queue processing, enqueueing jobs, and setting up middleware. Workers can be configured for different processing patterns including single message processing, batch processing, and various retry and visibility timeout strategies.

Examples:

Basic worker implementation

class EmailWorker
  include Shoryuken::Worker
  shoryuken_options queue: 'emails'

  def perform(sqs_msg, body)
    send_email(body['recipient'], body['subject'], body['content'])
  end
end

Advanced worker with all options

class AdvancedWorker
  include Shoryuken::Worker

  shoryuken_options queue: 'advanced_queue',
                    batch: false,
                    auto_delete: true,
                    auto_visibility_timeout: true,
                    retry_intervals: [1, 5, 25, 125, 625]

  server_middleware do |chain|
    chain.add MyCustomMiddleware
  end

  def perform(sqs_msg, body)
    # Worker implementation
  end
end

See Also:

Defined Under Namespace

Modules: ClassMethods Classes: DefaultExecutor, InlineExecutor

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



45
46
47
48
# File 'lib/shoryuken/worker.rb', line 45

def self.included(base)
  base.extend(ClassMethods)
  base.shoryuken_class_attribute :shoryuken_options_hash
end