mirror of
https://github.com/endofunky/sidetiq.git
synced 2022-11-09 13:53:30 -05:00
Remove experimental lock watcher worker.
This commit is contained in:
parent
bd11d6f8ca
commit
be803e212b
3 changed files with 0 additions and 66 deletions
|
@ -1,41 +0,0 @@
|
|||
Sidetiq.logger.warn "Sidetiq::Lock::Watcher is experimental and the behavior and API may change in a future version."
|
||||
|
||||
module Sidetiq
|
||||
configure do |config|
|
||||
config.lock = OpenStruct.new.tap do |lock|
|
||||
lock.watcher = OpenStruct.new.tap do |watcher|
|
||||
watcher.remove_lock = false
|
||||
watcher.notify = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Lock
|
||||
class Watcher
|
||||
class StaleLogError < StandardError; end
|
||||
|
||||
include Sidekiq::Worker
|
||||
include Sidekiq::ExceptionHandler
|
||||
include Sidetiq::Schedulable
|
||||
|
||||
recurrence do
|
||||
minutely.second_of_minute(0, 10, 20, 30, 40, 50)
|
||||
end
|
||||
|
||||
def perform
|
||||
Sidetiq::Lock::Redis.all.each do |lock|
|
||||
next unless lock.stale?
|
||||
|
||||
if Sidetiq.config.lock.watcher.remove_lock
|
||||
lock.unlock!
|
||||
end
|
||||
|
||||
if Sidetiq.config.lock.watcher.notify
|
||||
ex = StaleLogError.new("Stale lock detected: #{lock.key} (#{lock.meta_data})")
|
||||
handle_exception(ex, context: "Sidetiq::Lock::Watcher#perform")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,7 +12,6 @@ require 'rack/test'
|
|||
|
||||
require 'sidetiq'
|
||||
require 'sidetiq/web'
|
||||
require 'sidetiq/lock/watcher'
|
||||
|
||||
class Sidetiq::Supervisor
|
||||
def self.clock
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
require_relative 'helper'
|
||||
|
||||
class TestWatcher < Sidetiq::TestCase
|
||||
def setup
|
||||
Sidetiq.config.lock.watcher.remove_lock = true
|
||||
Sidetiq.config.lock.watcher.notify = true
|
||||
|
||||
@worker = Sidetiq::Lock::Watcher.new
|
||||
end
|
||||
|
||||
def test_perform
|
||||
Sidetiq::Lock::Redis.new("foobar", 1000000).lock
|
||||
|
||||
assert_equal 1, Sidetiq::Lock::Redis.all.length
|
||||
|
||||
@worker.expects(:handle_exception).once
|
||||
|
||||
@worker.perform
|
||||
|
||||
assert_equal 0, Sidetiq::Lock::Redis.all.length
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in a new issue