1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/middleware/server/timeout.rb

21 lines
364 B
Ruby

require 'timeout'
module Sidekiq
module Middleware
module Server
class Timeout
def call(worker, msg, queue)
if msg['timeout'] && msg['timeout'].to_i != 0
::Timeout.timeout(msg['timeout'].to_i) do
yield
end
else
yield
end
end
end
end
end
end