Module: Shoryuken::Middleware

Defined in:
lib/shoryuken/middleware/chain.rb,
lib/shoryuken/middleware/server/timing.rb,
lib/shoryuken/middleware/server/auto_delete.rb,
lib/shoryuken/middleware/server/active_record.rb,
lib/shoryuken/middleware/server/exponential_backoff_retry.rb

Overview

Middleware is code configured to run before/after a message is processed. It is patterned after Rack middleware. Middleware exists for the server side (when jobs are actually processed).

To modify middleware for the server, just call with another block:

Shoryuken.configure_server do |config|

config.server_middleware do |chain|
  chain.add MyServerHook
  chain.remove ActiveRecord
end

end

To insert immediately preceding another entry:

Shoryuken.configure_server do |config|

config.server_middleware do |chain|
  chain.insert_before ActiveRecord, MyServerHook
end

end

To insert immediately after another entry:

Shoryuken.configure_server do |config|

config.server_middleware do |chain|
  chain.insert_after ActiveRecord, MyServerHook
end

end

This is an example of a minimal server middleware:

class MyServerHook

def call(worker_instance, queue, sqs_msg)
  puts 'Before work'
  yield
  puts 'After work'
end

end

Defined Under Namespace

Modules: Server Classes: Chain, Entry