Module: Creeper::Middleware

Defined in:
lib/creeper/middleware/chain.rb,
lib/creeper/middleware/server/logging.rb,
lib/creeper/middleware/server/timeout.rb,
lib/creeper/middleware/server/retry_jobs.rb,
lib/creeper/middleware/server/active_record.rb

Overview

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

To add middleware for the client:

Creeper.configure_client do |config|

config.client_middleware do |chain|
  chain.add MyClientHook
end

end

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

Creeper.configure_server do |config|

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

end

This is an example of a minimal server middleware:

class MyServerHook

def call(worker_instance, msg, queue)
  puts "Before work"
  yield
  puts "After work"
end

end

This is an example of a minimal client middleware:

class MyClientHook

def call(worker_class, msg, queue)
  puts "Before push"
  yield
  puts "After push"
end

end

Defined Under Namespace

Modules: Server Classes: Chain, Entry