sidetiq 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e74875f92ae3dde7fe52ed987ee793e739b33410
4
- data.tar.gz: 3d11a3504aabcb2c039a77e039f3719a392a06e9
3
+ metadata.gz: 36f269a9187cd360dd8393dd5fef00396b2f85ed
4
+ data.tar.gz: ec0af2925a2258dbca828bfb2b8ad91c71b9a412
5
5
  SHA512:
6
- metadata.gz: 77728e60b7e676d22fde48e7718ce50deec35d2326eb338a409ab64a7455c36c43e6971f4cf36460ef7a37362d175610fa9f56700a705eaf464a08c49f603092
7
- data.tar.gz: 30dc8422161e6620872b702b5135c11cb507fba8f4183abd8cbaa6c1abc74e9b91e3b81e5026e47f45230560f2bf259beac9e5cfc233ada171c7e0d2a4981c01
6
+ metadata.gz: 1f6d3ffd5da1bcc3f2953236d3853c098755f9f27e8a15fa57f80f349bd1e27719f52c537e72aeb925538f3facf2b161db4e39f2a9020b103e64e13cde29df7f
7
+ data.tar.gz: 8bc91ee79a640e5bda063b0058eeacccfe8ac15d50ac984606bf7e2d81aaa67d8fe1259d4f5046cd0077d3f693f0001660f7a0868bddd55dfd682edac3975a1f
data/.travis.yml CHANGED
@@ -8,6 +8,7 @@ services:
8
8
  rvm:
9
9
  - 1.9.3
10
10
  - 2.0.0
11
+ - 2.1.1
11
12
  - jruby-19mode
12
13
  - rbx-19mode
13
14
  - ruby-head
@@ -18,6 +19,10 @@ jdk:
18
19
  - oraclejdk7
19
20
  matrix:
20
21
  exclude:
22
+ - rvm: 2.1.1
23
+ jdk: openjdk7
24
+ - rvm: 2.1.1
25
+ jdk: openjdk6
21
26
  - rvm: 2.0.0
22
27
  jdk: openjdk7
23
28
  - rvm: 2.0.0
@@ -37,4 +42,5 @@ matrix:
37
42
  allow_failures:
38
43
  - rvm: rbx-19mode
39
44
  - rvm: ruby-head
40
- - rvm: jruby-head
45
+ - rvm: jruby-head
46
+ - rvm: jruby-19mode
data/CHANGELOG.md CHANGED
@@ -1,7 +1,19 @@
1
+ 0.6.0
2
+ -----
3
+
4
+ - Explicitly require Sidekiq::ExceptionHandler [gglider]
5
+ - Fix config.utc [gglider]
6
+ - Add Ruby 2.1.1 to travix [gglider]
7
+ - Bump ice_cube dependency to 0.12.0 [toolmantim]
8
+ - Sort workers index page in web dashboard by name [oestrich]
9
+ - Reseting cached times when recurrence changes [LongMan]
10
+ - Move CSS to external files [futhr]
11
+
1
12
  0.5.0
2
13
  -----
3
14
 
4
15
  - Relax Sidekiq dependency. [leemhenson]
16
+
5
17
  0.4.3
6
18
  -----
7
19
 
data/lib/sidetiq/actor.rb CHANGED
@@ -27,7 +27,7 @@ module Sidetiq
27
27
  def link_to_sidekiq_manager
28
28
  Sidekiq::CLI.instance.launcher.manager.link(current_actor)
29
29
  rescue NoMethodError
30
- warn "Can't link #{self.class.name}. Sidekiq::Manager not running. Retrying in 5 seconds ..."
30
+ debug "Can't link #{self.class.name}. Sidekiq::Manager not running. Retrying in 5 seconds ..."
31
31
  after(5) { link_to_sidekiq_manager }
32
32
  end
33
33
 
@@ -1,3 +1,5 @@
1
+ require 'sidekiq/exception_handler'
2
+
1
3
  module Sidetiq
2
4
  class Handler
3
5
  include Logging
@@ -33,17 +33,44 @@ module Sidetiq
33
33
  get_timestamp "next"
34
34
  end
35
35
 
36
+ def schedule_description
37
+ get_schedulable_key("schedule_description")
38
+ end
39
+
36
40
  def recurrence(options = {}, &block) # :nodoc:
37
41
  schedule.instance_eval(&block)
38
42
  schedule.set_options(options)
43
+
44
+ # deleting schedulable keys if schedule changed since last reccurence definition
45
+ old_description = get_schedulable_key("schedule_description")
46
+ if old_description != schedule.to_s
47
+ get_schedulable_keys.map do |key|
48
+ schedulable_redis.del(key)
49
+ end
50
+ set_schedulable_key("schedule_description", schedule.to_s)
51
+ end
39
52
  end
40
53
 
41
54
  private
42
55
 
56
+ def schedulable_redis
57
+ Sidekiq.redis { |redis| redis }
58
+ end
59
+
60
+ def get_schedulable_keys
61
+ schedulable_redis.keys("sidetiq:#{name}:*")
62
+ end
63
+
64
+ def get_schedulable_key(key)
65
+ schedulable_redis.get("sidetiq:#{name}:#{key}")
66
+ end
67
+
68
+ def set_schedulable_key(key, value)
69
+ schedulable_redis.set("sidetiq:#{name}:#{key}", value)
70
+ end
71
+
43
72
  def get_timestamp(key)
44
- Sidekiq.redis do |redis|
45
- (redis.get("sidetiq:#{name}:#{key}") || -1).to_f
46
- end
73
+ (get_schedulable_key(key) || -1).to_f
47
74
  end
48
75
  end
49
76
 
@@ -9,10 +9,12 @@ module Sidetiq
9
9
 
10
10
  # Public: Start time offset from epoch used for calculating run
11
11
  # times in the Sidetiq schedules.
12
- START_TIME = Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1)
12
+ def self.start_time
13
+ Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1)
14
+ end
13
15
 
14
16
  def initialize # :nodoc:
15
- @schedule = IceCube::Schedule.new(START_TIME)
17
+ @schedule = IceCube::Schedule.new(self.class.start_time)
16
18
  end
17
19
 
18
20
  def method_missing(meth, *args, &block) # :nodoc:
@@ -32,8 +34,8 @@ module Sidetiq
32
34
  # Returns true if a job is due, otherwise false.
33
35
  def schedule_next?(time)
34
36
  next_occurrence = @schedule.next_occurrence(time)
35
- if @last_scheduled != next_occurrence
36
- @last_scheduled = next_occurrence
37
+ if @last_scheduled != next_occurrence.to_i
38
+ @last_scheduled = next_occurrence.to_i
37
39
  return true
38
40
  end
39
41
  false
@@ -5,7 +5,7 @@ module Sidetiq
5
5
  MAJOR = 0
6
6
 
7
7
  # Public: Sidetiq minor version number.
8
- MINOR = 5
8
+ MINOR = 6
9
9
 
10
10
  # Public: Sidetiq patch level.
11
11
  PATCH = 0
@@ -0,0 +1,21 @@
1
+
2
+ .table-sidetiq {
3
+ width: 100%;
4
+ margin: 0;
5
+ table-layout: fixed;
6
+ }
7
+
8
+ .backtrace {
9
+ display: none;
10
+ overflow: auto;
11
+ width: 100%;
12
+ background: white;
13
+ }
14
+
15
+ .backtrace pre {
16
+ display: inline-block;
17
+ font-size: 0.8em;
18
+ border: none;
19
+ white-space: nowrap;
20
+ margin: 0;
21
+ }
@@ -1,4 +1,6 @@
1
- <%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %>
1
+ <style>
2
+ <%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
3
+ </style>
2
4
 
3
5
  <header class="row">
4
6
  <div class="col-md-5">
@@ -8,10 +10,10 @@
8
10
 
9
11
  <div class="container">
10
12
  <div class="row">
11
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_worker_nav.erb')) %>
13
+ <%= erb File.read(File.join(view_path, '_worker_nav.erb')) %>
12
14
 
13
15
  <div class="col-md-9">
14
- <table class="table table-striped table-bordered table-hover table-white" style="width: 100%; margin: 0; table-layout:fixed;">
16
+ <table class="table table-striped table-bordered table-hover table-white table-sidetiq">
15
17
  <thead>
16
18
  <th style="width: 10%">Status</th>
17
19
  <th style="width: 20%">Timestamp</th>
@@ -28,8 +30,8 @@
28
30
  <a class="backtrace" href="#" onclick="$(this).next().toggle(); return false">
29
31
  <%= entry[:exception] %>: <%= entry[:error] %>
30
32
  </a>
31
- <div style="display: none; overflow: auto; width: 100%; background: white; ">
32
- <pre style="display: inline-block; font-size: 0.8em; border: none; white-space: nowrap; margin: 0">
33
+ <div class="backtrace">
34
+ <pre>
33
35
  <%= entry[:backtrace].join("<br />") %>
34
36
  </pre>
35
37
  </div>
@@ -1,4 +1,6 @@
1
- <%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %>
1
+ <style>
2
+ <%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
3
+ </style>
2
4
 
3
5
  <header class="row">
4
6
  <div class="col-md-5">
@@ -8,11 +10,11 @@
8
10
 
9
11
  <div class="container">
10
12
  <div class="row">
11
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_home_nav.erb')) %>
13
+ <%= erb File.read(File.join(view_path, '_home_nav.erb')) %>
12
14
 
13
15
  <div class="col-md-9">
14
16
  <% if @locks.length > 0 %>
15
- <table class="table table-striped table-bordered table-white" style="width: 100%; margin: 0; table-layout:fixed;">
17
+ <table class="table table-striped table-bordered table-white table-sidetiq">
16
18
  <thead>
17
19
  <th style="width: 20%">Key</th>
18
20
  <th style="width: 30%">Owner Node</th>
@@ -1,4 +1,6 @@
1
- <%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %>
1
+ <style>
2
+ <%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
3
+ </style>
2
4
 
3
5
  <header class="row">
4
6
  <div class="col-md-5">
@@ -8,11 +10,11 @@
8
10
 
9
11
  <div class="container">
10
12
  <div class="row">
11
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_worker_nav.erb')) %>
13
+ <%= erb File.read(File.join(view_path, '_worker_nav.erb')) %>
12
14
 
13
15
  <div class="col-md-9">
14
16
  <% if (recurrences = @schedule.recurrence_rules).length > 0 %>
15
- <table class="table table-striped table-bordered table-hover table-white" style="width: 100%; margin: 0; table-layout:fixed;">
17
+ <table class="table table-striped table-bordered table-hover table-white table-sidetiq">
16
18
  <thead>
17
19
  <th>Recurrences</th>
18
20
  </thead>
@@ -27,7 +29,7 @@
27
29
  <br />
28
30
 
29
31
  <% if (exceptions = @schedule.exception_rules).length > 0 %>
30
- <table class="table table-striped table-bordered table-hover table-white" style="width: 100%; margin: 0; table-layout:fixed;">
32
+ <table class="table table-striped table-bordered table-hover table-white table-sidetiq">
31
33
  <thead>
32
34
  <th>Exceptions</th>
33
35
  </thead>
@@ -41,7 +43,7 @@
41
43
 
42
44
  <br />
43
45
 
44
- <table class="table table-striped table-bordered table-hover table-white" style="width: 100%; margin: 0; table-layout:fixed;">
46
+ <table class="table table-striped table-bordered table-hover table-white table-sidetiq">
45
47
  <thead>
46
48
  <th style="width: 25%">Next 10 runs</th>
47
49
  <th style="width: 75%" />
@@ -1,4 +1,6 @@
1
- <%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %>
1
+ <style>
2
+ <%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
3
+ </style>
2
4
 
3
5
  <header class="row">
4
6
  <div class="col-sm-5">
@@ -8,11 +10,11 @@
8
10
 
9
11
  <div class="container">
10
12
  <div class="row">
11
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_home_nav.erb')) %>
13
+ <%= erb File.read(File.join(view_path, '_home_nav.erb')) %>
12
14
 
13
15
  <div class="col-md-9">
14
16
  <% if @workers.length > 0 %>
15
- <table class="table table-striped table-bordered table-white" style="width: 100%; margin: 0; table-layout:fixed;">
17
+ <table class="table table-striped table-bordered table-white table-sidetiq">
16
18
  <thead>
17
19
  <th style="width: 50%">Worker</th>
18
20
  <th style="width: 10%">Queue</th>
data/lib/sidetiq/web.rb CHANGED
@@ -6,15 +6,15 @@ module Sidetiq
6
6
 
7
7
  def self.registered(app)
8
8
  app.get "/sidetiq" do
9
- @workers = Sidetiq.workers
9
+ @workers = Sidetiq.workers.sort_by { |worker| worker.name }
10
10
  @time = Sidetiq.clock.gettime
11
- erb File.read(File.join(VIEWS, 'sidetiq.erb'))
11
+ erb File.read(File.join(VIEWS, 'sidetiq.erb')), locals: {view_path: VIEWS}
12
12
  end
13
13
 
14
14
  app.get "/sidetiq/locks" do
15
15
  @locks = Sidetiq::Lock::Redis.all.map(&:meta_data)
16
16
 
17
- erb File.read(File.join(VIEWS, 'locks.erb'))
17
+ erb File.read(File.join(VIEWS, 'locks.erb')), locals: {view_path: VIEWS}
18
18
  end
19
19
 
20
20
  app.get "/sidetiq/:name/schedule" do
@@ -28,7 +28,7 @@ module Sidetiq
28
28
 
29
29
  @schedule = @worker.schedule
30
30
 
31
- erb File.read(File.join(VIEWS, 'schedule.erb'))
31
+ erb File.read(File.join(VIEWS, 'schedule.erb')), locals: {view_path: VIEWS}
32
32
  end
33
33
 
34
34
  app.get "/sidetiq/:name/history" do
@@ -44,7 +44,7 @@ module Sidetiq
44
44
  redis.lrange("sidetiq:#{name}:history", 0, -1)
45
45
  end
46
46
 
47
- erb File.read(File.join(VIEWS, 'history.erb'))
47
+ erb File.read(File.join(VIEWS, 'history.erb')), locals: {view_path: VIEWS}
48
48
  end
49
49
 
50
50
  app.post "/sidetiq/:name/trigger" do
data/sidetiq.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.add_dependency 'sidekiq', '>= 2.16.0'
23
23
  gem.add_dependency 'celluloid', '>= 0.14.1'
24
- gem.add_dependency 'ice_cube', '~> 0.11.0'
24
+ gem.add_dependency 'ice_cube', '~> 0.12.0'
25
25
 
26
26
  gem.add_development_dependency 'rake'
27
27
  gem.add_development_dependency 'sinatra'
data/test/helper.rb CHANGED
@@ -12,7 +12,6 @@ require 'rack/test'
12
12
 
13
13
  require 'sidetiq'
14
14
  require 'sidetiq/web'
15
- require 'sidetiq/lock/watcher'
16
15
 
17
16
  class Sidetiq::Supervisor
18
17
  def self.clock
data/test/test_clock.rb CHANGED
@@ -19,7 +19,7 @@ class TestClock < Sidetiq::TestCase
19
19
  def test_backfilling
20
20
  BackfillWorker.jobs.clear
21
21
  Sidetiq.stubs(:workers).returns([BackfillWorker])
22
- start = Sidetiq::Schedule::START_TIME
22
+ start = Sidetiq::Schedule.start_time
23
23
 
24
24
  BackfillWorker.stubs(:last_scheduled_occurrence).returns(start.to_f)
25
25
  clock.stubs(:gettime).returns(start)
@@ -0,0 +1,45 @@
1
+ require_relative 'helper'
2
+
3
+ class TestShedulable < Sidetiq::TestCase
4
+ class FakeWorker
5
+ include Sidetiq::Schedulable
6
+ end
7
+
8
+ def test_resheduling
9
+ last_run = (Time.now - 100).to_f
10
+ next_run = (Time.now + 100).to_f
11
+
12
+ Sidekiq.redis do |redis|
13
+ redis.set "sidetiq:TestShedulable::FakeWorker:last", last_run
14
+ redis.set "sidetiq:TestShedulable::FakeWorker:next", next_run
15
+ end
16
+
17
+ assert FakeWorker.schedule_description == nil
18
+
19
+ FakeWorker.schedule = nil
20
+ FakeWorker.recurrence { minutely }
21
+
22
+ assert FakeWorker.schedule_description == "Minutely"
23
+ assert FakeWorker.last_scheduled_occurrence == -1.0
24
+ assert FakeWorker.next_scheduled_occurrence == -1.0
25
+
26
+ Sidekiq.redis do |redis|
27
+ redis.set "sidetiq:TestShedulable::FakeWorker:last", last_run
28
+ redis.set "sidetiq:TestShedulable::FakeWorker:next", next_run
29
+ end
30
+
31
+ FakeWorker.schedule = nil
32
+ FakeWorker.recurrence { minutely }
33
+
34
+ assert FakeWorker.schedule_description == "Minutely"
35
+ assert FakeWorker.last_scheduled_occurrence == last_run
36
+ assert FakeWorker.next_scheduled_occurrence == next_run
37
+
38
+ FakeWorker.schedule = nil
39
+ FakeWorker.recurrence { hourly }
40
+
41
+ assert FakeWorker.schedule_description == "Hourly"
42
+ assert FakeWorker.last_scheduled_occurrence == -1.0
43
+ assert FakeWorker.next_scheduled_occurrence == -1.0
44
+ end
45
+ end
@@ -34,5 +34,12 @@ class TestSchedule < Sidetiq::TestCase
34
34
  sched.set_options(backfill: false)
35
35
  refute sched.backfill?
36
36
  end
37
+
38
+ def test_use_utc
39
+ Sidetiq.config.utc = true
40
+ assert_equal(Time.utc(2010, 01, 01), Sidetiq::Schedule.new.start_time)
41
+ ensure
42
+ Sidetiq.config.utc = false
43
+ end
37
44
  end
38
45
 
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidetiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Svensson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-26 00:00:00.000000000 Z
11
+ date: 2014-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.16.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: celluloid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.14.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.14.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ice_cube
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.11.0
47
+ version: 0.12.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.11.0
54
+ version: 0.12.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sinatra
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mocha
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rack-test
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: minitest
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 5.0.7
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 5.0.7
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: coveralls
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Recurring jobs for Sidekiq
@@ -143,8 +143,8 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - .gitignore
147
- - .travis.yml
146
+ - ".gitignore"
147
+ - ".travis.yml"
148
148
  - CHANGELOG.md
149
149
  - Gemfile
150
150
  - LICENSE
@@ -165,7 +165,6 @@ files:
165
165
  - lib/sidetiq/handler.rb
166
166
  - lib/sidetiq/lock/meta_data.rb
167
167
  - lib/sidetiq/lock/redis.rb
168
- - lib/sidetiq/lock/watcher.rb
169
168
  - lib/sidetiq/logging.rb
170
169
  - lib/sidetiq/middleware/history.rb
171
170
  - lib/sidetiq/schedulable.rb
@@ -197,11 +196,11 @@ files:
197
196
  - test/test_history.rb
198
197
  - test/test_lock_meta_data.rb
199
198
  - test/test_lock_redis.rb
199
+ - test/test_schedulable.rb
200
200
  - test/test_schedule.rb
201
201
  - test/test_sidetiq.rb
202
202
  - test/test_subclass_tracking.rb
203
203
  - test/test_version.rb
204
- - test/test_watcher.rb
205
204
  - test/test_web.rb
206
205
  - test/test_worker.rb
207
206
  homepage: http://github.com/tobiassvn/sidetiq
@@ -214,17 +213,17 @@ require_paths:
214
213
  - lib
215
214
  required_ruby_version: !ruby/object:Gem::Requirement
216
215
  requirements:
217
- - - '>='
216
+ - - ">="
218
217
  - !ruby/object:Gem::Version
219
218
  version: '0'
220
219
  required_rubygems_version: !ruby/object:Gem::Requirement
221
220
  requirements:
222
- - - '>='
221
+ - - ">="
223
222
  - !ruby/object:Gem::Version
224
223
  version: '0'
225
224
  requirements: []
226
225
  rubyforge_project:
227
- rubygems_version: 2.0.3
226
+ rubygems_version: 2.2.2
228
227
  signing_key:
229
228
  specification_version: 4
230
229
  summary: Recurring jobs for Sidekiq
@@ -242,10 +241,10 @@ test_files:
242
241
  - test/test_history.rb
243
242
  - test/test_lock_meta_data.rb
244
243
  - test/test_lock_redis.rb
244
+ - test/test_schedulable.rb
245
245
  - test/test_schedule.rb
246
246
  - test/test_sidetiq.rb
247
247
  - test/test_subclass_tracking.rb
248
248
  - test/test_version.rb
249
- - test/test_watcher.rb
250
249
  - test/test_web.rb
251
250
  - test/test_worker.rb
@@ -1,41 +0,0 @@
1
- Sidetiq.logger.warn "Sidetiq::Lock::Watcher is experimental and the behavior and API may change in a future version."
2
-
3
- module Sidetiq
4
- configure do |config|
5
- config.lock = OpenStruct.new.tap do |lock|
6
- lock.watcher = OpenStruct.new.tap do |watcher|
7
- watcher.remove_lock = false
8
- watcher.notify = true
9
- end
10
- end
11
- end
12
-
13
- module Lock
14
- class Watcher
15
- class StaleLogError < StandardError; end
16
-
17
- include Sidekiq::Worker
18
- include Sidekiq::ExceptionHandler
19
- include Sidetiq::Schedulable
20
-
21
- recurrence do
22
- minutely.second_of_minute(0, 10, 20, 30, 40, 50)
23
- end
24
-
25
- def perform
26
- Sidetiq::Lock::Redis.all.each do |lock|
27
- next unless lock.stale?
28
-
29
- if Sidetiq.config.lock.watcher.remove_lock
30
- lock.unlock!
31
- end
32
-
33
- if Sidetiq.config.lock.watcher.notify
34
- ex = StaleLogError.new("Stale lock detected: #{lock.key} (#{lock.meta_data})")
35
- handle_exception(ex, context: "Sidetiq::Lock::Watcher#perform")
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
data/test/test_watcher.rb DELETED
@@ -1,24 +0,0 @@
1
- require_relative 'helper'
2
-
3
- class TestWatcher < Sidetiq::TestCase
4
- def setup
5
- Sidetiq.config.lock.watcher.remove_lock = true
6
- Sidetiq.config.lock.watcher.notify = true
7
-
8
- @worker = Sidetiq::Lock::Watcher.new
9
- end
10
-
11
- def test_perform
12
- Sidetiq::Lock::Redis.new("foobar", 1000000).lock
13
-
14
- assert_equal 1, Sidetiq::Lock::Redis.all.length
15
-
16
- @worker.expects(:handle_exception).once
17
-
18
- @worker.perform
19
-
20
- assert_equal 0, Sidetiq::Lock::Redis.all.length
21
- end
22
- end
23
-
24
-