From be803e212b548ed8bc3cd7f20817dd297ffef72c Mon Sep 17 00:00:00 2001 From: Tobias Svensson Date: Fri, 6 Jun 2014 11:43:53 +0100 Subject: [PATCH] Remove experimental lock watcher worker. --- lib/sidetiq/lock/watcher.rb | 41 ------------------------------------- test/helper.rb | 1 - test/test_watcher.rb | 24 ---------------------- 3 files changed, 66 deletions(-) delete mode 100644 lib/sidetiq/lock/watcher.rb delete mode 100644 test/test_watcher.rb diff --git a/lib/sidetiq/lock/watcher.rb b/lib/sidetiq/lock/watcher.rb deleted file mode 100644 index 0082d86..0000000 --- a/lib/sidetiq/lock/watcher.rb +++ /dev/null @@ -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 diff --git a/test/helper.rb b/test/helper.rb index c204659..a9cd45f 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -12,7 +12,6 @@ require 'rack/test' require 'sidetiq' require 'sidetiq/web' -require 'sidetiq/lock/watcher' class Sidetiq::Supervisor def self.clock diff --git a/test/test_watcher.rb b/test/test_watcher.rb deleted file mode 100644 index 27d92c5..0000000 --- a/test/test_watcher.rb +++ /dev/null @@ -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 - -