Module: CaptainConfig::SidekiqMiddlewareFactory

Defined in:
lib/captain_config/middlewares/sidekiq_middleware_factory.rb

Defined Under Namespace

Modules: SidekiqMiddleware

Class Method Summary collapse

Class Method Details

.build(interval: 1.0) ⇒ Object

Since Sidekiq calls ‘.new` on the middleware class for every job we cannot store state in the instance between jobs like we would with a Rack middleware. Therefore we need to build a new class to hold that state.

interval: - Minimum time (in seconds) that must pass between reloading

configuration.


8
9
10
11
12
13
14
# File 'lib/captain_config/middlewares/sidekiq_middleware_factory.rb', line 8

def self.build(interval: 1.0)
  klass = Class.new do
    include SidekiqMiddleware
  end
  klass.setup(interval: interval)
  klass
end