Method: Sidekiq::Middleware::Chain#add

Defined in:
lib/sidekiq/middleware/chain.rb

#add(klass, *args) ⇒ Object

Add the given middleware to the end of the chain. Sidekiq will call ‘klass.new(*args)` to create a clean copy of your middleware for every job executed.

chain.add(Statsd::Metrics, { collector: "localhost:8125" })

Parameters:

  • klass (Class)

    Your middleware class

  • *args (Array<Object>)

    Set of arguments to pass to every instance of your middleware



119
120
121
122
# File 'lib/sidekiq/middleware/chain.rb', line 119

def add(klass, *args)
  remove(klass)
  entries << Entry.new(@config, klass, *args)
end