resque-scheduler 2.5.4 → 2.5.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of resque-scheduler might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e0ce99a734298a549762b23f47785be5667966a
4
- data.tar.gz: 6afeb5b9d56d492974e546a5f02b07e5a187de29
3
+ metadata.gz: 62efe393e6b613cf1d08a9d757105c124976010d
4
+ data.tar.gz: 9e61be4df36fa45b2e46ce09b97d8460481bf814
5
5
  SHA512:
6
- metadata.gz: ca01e37f6f95d63381c991e15334886882b1a0ec3808235fc8d4e2b388c2fb27540d5656900e5b65a73b199436d638b393ec02431a198ce338407a7490f2e776
7
- data.tar.gz: 84d9c9d293009c89ddbb7362d1741ceef87f74fd31636c1631c7a1ce731eb4fbf118263f92ab2af393dfd3898fb8de6ec94bbf208940ed15213c07104c974442
6
+ metadata.gz: 031282aff18c1d4ed4b57b906190adcae00c303cfa50ef66cbe6823761da44180194e64f15d5e81474486092e71a86d24d258294092dc00b2da5f2a27bd26024
7
+ data.tar.gz: 310937e91fd414c72d95f5394e9dd38090a6e291ba94b78cbab470e5ca9dd92c8365853c0244460e0934cafbac43835fe97adcc0c6de63d4c3eecee5737dac48
data/HISTORY.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Resque Scheduler History / ChangeLog / Release Notes
2
2
 
3
+ ## 2.5.5 (2014-02-27)
4
+ * Only showing link to job with args if job is present
5
+ * Only showing scheduled jobs that match current env or omit env
6
+ * Ensuring lock and acquire lua scripts are refreshed on timeout change
7
+ * Switch to using `mono_logger` instead of stdlib `logger`
8
+
3
9
  ## 2.5.4 (2014-02-17)
4
10
  * Documentation updates
5
11
 
data/README.md CHANGED
@@ -145,9 +145,9 @@ scheduled job must run (coerced with `Kernel#Float()`) (default `5`)
145
145
  default `'text'`)
146
146
  * `PIDFILE` - If non-empty, write process PID to file (default empty)
147
147
  * `QUIET` or `MUTE` - Silence most output if non-empty (equivalent to
148
- a level of `Logger::FATAL`, default `false`)
148
+ a level of `MonoLogger::FATAL`, default `false`)
149
149
  * `VERBOSE` - Maximize log verbosity if non-empty (equivalent to a level
150
- of `Logger::DEBUG`, default `false`)
150
+ of `MonoLogger::DEBUG`, default `false`)
151
151
 
152
152
 
153
153
  ### Resque Pool integration
@@ -20,6 +20,15 @@ module Resque
20
20
  ).to_i == 1
21
21
  end
22
22
 
23
+ def timeout=(seconds)
24
+ if locked?
25
+ @timeout = seconds
26
+ @locked_sha = nil
27
+ @acquire_sha = nil
28
+ end
29
+ @timeout
30
+ end
31
+
23
32
  private
24
33
 
25
34
  def locked_sha(refresh = false)
@@ -1,5 +1,7 @@
1
1
  # vim:fileencoding=utf-8
2
2
 
3
+ require 'mono_logger'
4
+
3
5
  module ResqueScheduler
4
6
  # Just builds a logger, with specified verbosity and destination.
5
7
  # The simplest example:
@@ -26,9 +28,9 @@ module ResqueScheduler
26
28
  @format = opts[:format] || 'text'
27
29
  end
28
30
 
29
- # Returns an instance of Logger
31
+ # Returns an instance of MonoLogger
30
32
  def build
31
- logger = Logger.new(@log_dev)
33
+ logger = MonoLogger.new(@log_dev)
32
34
  logger.level = level
33
35
  logger.formatter = send(:"#{@format}_formatter")
34
36
  logger
@@ -38,11 +40,11 @@ module ResqueScheduler
38
40
 
39
41
  def level
40
42
  if @verbose && !@muted
41
- Logger::DEBUG
43
+ MonoLogger::DEBUG
42
44
  elsif !@muted
43
- Logger::INFO
45
+ MonoLogger::INFO
44
46
  else
45
- Logger::FATAL
47
+ MonoLogger::FATAL
46
48
  end
47
49
  end
48
50
 
@@ -82,6 +82,11 @@ module ResqueScheduler
82
82
  config['class']
83
83
  end
84
84
  end
85
+
86
+ def scheduled_in_this_env?(name)
87
+ return true if Resque.schedule[name]['rails_env'].nil?
88
+ Resque.schedule[name]['rails_env'] == Resque::Scheduler.env
89
+ end
85
90
  end
86
91
 
87
92
  get "/schedule" do
@@ -40,7 +40,11 @@
40
40
  <% end %>
41
41
  </td>
42
42
  <td><%= h(job['args'].inspect) if job && delayed_timestamp_size == 1 %></td>
43
- <td><a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a></td>
43
+ <td>
44
+ <% if job %>
45
+ <a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
46
+ <% end %>
47
+ </td>
44
48
  </tr>
45
49
  <% end %>
46
50
  </table>
@@ -16,7 +16,7 @@
16
16
  <th>Queue</th>
17
17
  <th>Arguments</th>
18
18
  </tr>
19
- <% Resque.schedule.keys.sort.each do |name| %>
19
+ <% Resque.schedule.keys.sort.select { |n| scheduled_in_this_env?(n) }.each do |name| %>
20
20
  <% config = Resque.schedule[name] %>
21
21
  <tr>
22
22
  <td style="padding-top: 12px; padding-bottom: 2px; width: 10px">
@@ -1,5 +1,5 @@
1
1
  # vim:fileencoding=utf-8
2
2
 
3
3
  module ResqueScheduler
4
- VERSION = '2.5.4'
4
+ VERSION = '2.5.5'
5
5
  end
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'rubocop' unless RUBY_VERSION < '1.9'
30
30
  spec.add_development_dependency 'simplecov' unless RUBY_VERSION < '1.9'
31
31
 
32
+ spec.add_runtime_dependency 'mono_logger', '~> 1.0'
32
33
  spec.add_runtime_dependency 'redis', '~> 3.0.4'
33
34
  spec.add_runtime_dependency 'resque', '~> 1.25.1'
34
35
  spec.add_runtime_dependency 'rufus-scheduler', '~> 2.0.24'
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  context "on GET to /schedule with scheduled jobs" do
13
13
  setup do
14
- ENV['rails_env'] = 'production'
14
+ Resque::Scheduler.env = 'production'
15
15
  Resque.schedule = {
16
16
  'some_ivar_job' => {
17
17
  'cron' => "* * * * *",
@@ -26,6 +26,13 @@ context "on GET to /schedule with scheduled jobs" do
26
26
  'args' => {
27
27
  'b' => 'blah'
28
28
  }
29
+ },
30
+ 'some_fancy_job' => {
31
+ 'every' => ['1m'],
32
+ 'queue' => 'fancy',
33
+ 'class' => 'SomeFancyJob',
34
+ 'args' => 'sparkles',
35
+ 'rails_env' => 'fancy'
29
36
  }
30
37
  }
31
38
  Resque::Scheduler.load_schedule!
@@ -37,6 +44,10 @@ context "on GET to /schedule with scheduled jobs" do
37
44
  test 'see the scheduled job' do
38
45
  assert last_response.body.include?('SomeIvarJob')
39
46
  end
47
+
48
+ test 'excludes jobs for other envs' do
49
+ assert !last_response.body.include?('SomeFancyJob')
50
+ end
40
51
  end
41
52
 
42
53
  context "on GET to /delayed" do
@@ -238,5 +238,54 @@ context 'Resque::Scheduler::Lock::Resilient' do
238
238
 
239
239
  assert Resque.redis.ttl(@lock.key) <= 10, "TTL should not have been updated"
240
240
  end
241
+
242
+ test 'setting the lock timeout changes the key TTL if we hold it' do
243
+ @lock.acquire!
244
+
245
+ @lock.stubs(:locked?).returns(true)
246
+ @lock.timeout = 120
247
+ ttl = Resque.redis.ttl(@lock.key)
248
+ assert_send [ttl, :>, 100]
249
+
250
+ @lock.stubs(:locked?).returns(true)
251
+ @lock.timeout = 180
252
+ ttl = Resque.redis.ttl(@lock.key)
253
+ assert_send [ttl, :>, 120]
254
+ end
255
+
256
+ test 'setting lock timeout is a noop if not held' do
257
+ @lock.acquire!
258
+ @lock.timeout = 100
259
+ @lock.stubs(:locked?).returns(false)
260
+ @lock.timeout = 120
261
+ assert_equal 100, @lock.timeout
262
+ end
263
+
264
+ test 'setting lock timeout nils out lock script' do
265
+ @lock.acquire!
266
+ @lock.timeout = 100
267
+ assert_equal nil, @lock.instance_variable_get(:@locked_sha)
268
+ end
269
+
270
+ test 'setting lock timeout does not nil out lock script if not held' do
271
+ @lock.acquire!
272
+ @lock.locked?
273
+ @lock.stubs(:locked?).returns(false)
274
+ @lock.timeout = 100
275
+ assert_not_nil @lock.instance_variable_get(:@locked_sha)
276
+ end
277
+
278
+ test 'setting lock timeout nils out acquire script' do
279
+ @lock.acquire!
280
+ @lock.timeout = 100
281
+ assert_equal nil, @lock.instance_variable_get(:@acquire_sha)
282
+ end
283
+
284
+ test 'setting lock timeout does not nil out acquire script if not held' do
285
+ @lock.acquire!
286
+ @lock.stubs(:locked?).returns(false)
287
+ @lock.timeout = 100
288
+ assert_not_nil @lock.instance_variable_get(:@acquire_sha)
289
+ end
241
290
  end
242
291
  end
@@ -12,7 +12,7 @@ context "Resque::Scheduler" do
12
12
  teardown { restore_devnull_logfile }
13
13
 
14
14
  test 'set custom logger' do
15
- custom_logger = Logger.new('/dev/null')
15
+ custom_logger = MonoLogger.new('/dev/null')
16
16
  Resque::Scheduler.logger = custom_logger
17
17
  assert_equal(custom_logger, Resque::Scheduler.logger)
18
18
  end
@@ -62,11 +62,11 @@ context "Resque::Scheduler" do
62
62
  end
63
63
 
64
64
  test 'not verbose' do
65
- assert Resque::Scheduler.logger.level > Logger::DEBUG
65
+ assert Resque::Scheduler.logger.level > MonoLogger::DEBUG
66
66
  end
67
67
 
68
68
  test 'not muted' do
69
- assert Resque::Scheduler.logger.level < Logger::FATAL
69
+ assert Resque::Scheduler.logger.level < MonoLogger::FATAL
70
70
  end
71
71
  end
72
72
 
@@ -84,12 +84,12 @@ context "Resque::Scheduler" do
84
84
 
85
85
  test 'set verbosity' do
86
86
  Resque::Scheduler.verbose = true
87
- assert Resque::Scheduler.logger.level == Logger::DEBUG
87
+ assert Resque::Scheduler.logger.level == MonoLogger::DEBUG
88
88
  end
89
89
 
90
90
  test 'mute logger' do
91
91
  Resque::Scheduler.mute = true
92
- assert Resque::Scheduler.logger.level == Logger::FATAL
92
+ assert Resque::Scheduler.logger.level == MonoLogger::FATAL
93
93
  end
94
94
  end
95
95
  end
@@ -81,6 +81,12 @@ class SomeIvarJob < SomeJob
81
81
  @queue = :ivar
82
82
  end
83
83
 
84
+ class SomeFancyJob < SomeJob
85
+ def self.queue
86
+ :fancy
87
+ end
88
+ end
89
+
84
90
  class SomeQuickJob < SomeJob
85
91
  @queue = :quick
86
92
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
4
+ version: 2.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben VandenBos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-17 00:00:00.000000000 Z
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mono_logger
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: redis
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -241,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
255
  version: '0'
242
256
  requirements: []
243
257
  rubyforge_project:
244
- rubygems_version: 2.0.3
258
+ rubygems_version: 2.0.14
245
259
  signing_key:
246
260
  specification_version: 4
247
261
  summary: Light weight job scheduling on top of Resque