mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
1st crack at timeouts
This commit is contained in:
parent
f8e92f282c
commit
34543f10d9
1 changed files with 20 additions and 0 deletions
20
lib/sidekiq/middleware/server/timeout.rb
Normal file
20
lib/sidekiq/middleware/server/timeout.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'timeout'
|
||||
module Sidekiq
|
||||
module Middleware
|
||||
module Server
|
||||
class Timeout
|
||||
@timeout_in_seconds
|
||||
|
||||
def initialize(options={:timeout => 120})
|
||||
@timeout_in_seconds = options[:timeout]
|
||||
end
|
||||
|
||||
def call(worker, msg, queue)
|
||||
Timeout::timeout (@timeout_in_seconds) {
|
||||
yield
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue