Class: Sidetiq::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sidetiq/middleware.rb

Instance Method Summary collapse

Constructor Details

#initializeMiddleware

Returns a new instance of Middleware.



3
4
5
# File 'lib/sidetiq/middleware.rb', line 3

def initialize
  @clock = Sidetiq::Clock.instance
end

Instance Method Details

#call(*args) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/sidetiq/middleware.rb', line 7

def call(*args)
  # Restart the clock if the thread died.
  if !@clock.ticking?
    Sidetiq.logger.warn "Sidetiq::Clock thread died. Restarting..."
    @clock.start!
  end
  yield
end