resque-scheduler 4.4.0 → 4.5.0

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
  SHA256:
3
- metadata.gz: 0d023543334a4b91f16d2c055415ee69cb7d1d8a7cf8219c63b7041d6cd83dfe
4
- data.tar.gz: 905a6a650435f19ae58c6cd7cbb6c260485dd23a4335c0cc6a94f285611df783
3
+ metadata.gz: 2c97d0ecaec5a456e20e91d98779f7792fafd99e09f1bfd85452234a01ba47c0
4
+ data.tar.gz: f3947f2446b6ddac4d5555d467a302a3032a08d3dd77bdc039253674f70a85e1
5
5
  SHA512:
6
- metadata.gz: 163b20de37de1fba902be2e744cf61b716e04610b391b510f4fe2cbd47aa22299b4a012994a62a928063d749520121cacc58609e10a7b7d1c17126aeb1e5aa49
7
- data.tar.gz: bb1be8accb32a7d682198bdff57b2958526408a1e54093315c322b6a1c69905c6548763057957a563a0fd553c62e5d557b5fad2a5ae6b6f11ba26355ec6270b9
6
+ metadata.gz: cbfefeb510538682d188284280ca56af1641de3dde1a63ad8b79b5a09dcc916dc902839782a9ad988421c77b84146a05b4077291aa754e24d07dc75440786c2e
7
+ data.tar.gz: 955193ba760e37bd6f58f94a4ba67edab755329a68e4deefa0466c822d3fbd3d057cf357a410bedf23fd145b687255b3fe783d44890d7d4dfd0307773c1baeb5
@@ -0,0 +1,12 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+
9
+ - package-ecosystem: "bundler"
10
+ directory: "/"
11
+ schedule:
12
+ interval: "weekly"
@@ -0,0 +1,27 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ rubocop:
11
+ name: Rubocop
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ matrix:
15
+ os: [ubuntu-latest]
16
+ ruby: [
17
+ 2.4
18
+ ]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Ruby linter
27
+ run: bundle exec rubocop
@@ -0,0 +1,48 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ services:
13
+ redis:
14
+ image: redis
15
+ ports:
16
+ - 6379:6379
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ ruby-version:
21
+ - 2.3
22
+ - 2.4
23
+ - 2.5
24
+ - 2.6
25
+ - 2.7
26
+ - "3.0"
27
+ - head
28
+ - jruby-9.1.17.0
29
+ - jruby-9.2.9.0
30
+ - jruby-9.2.19.0
31
+ resque-version:
32
+ - "master"
33
+ - "~> 2.0.0"
34
+ - "~> 1.27"
35
+ env:
36
+ RESQUE: "${{ matrix.resque-version }}"
37
+ COVERAGE: 1
38
+ JRUBY_OPTS: ""
39
+ RUBYOPT: "-W0"
40
+
41
+ steps:
42
+ - uses: actions/checkout@v2
43
+ - uses: ruby/setup-ruby@v1
44
+ with:
45
+ ruby-version: "${{ matrix.ruby-version }}"
46
+ bundler-cache: true
47
+ - run: bundle exec rake
48
+ - run: bin/bundle_console_test.sh
data/AUTHORS.md CHANGED
@@ -30,6 +30,7 @@ Resque Scheduler authors
30
30
  - Ian Davies
31
31
  - James Le Cuirot
32
32
  - Jarkko Mönkkönen
33
+ - Jimmy Chao
33
34
  - John Crepezzi
34
35
  - John Griffin
35
36
  - Jon Larkowski and Les Hill
@@ -62,11 +63,13 @@ Resque Scheduler authors
62
63
  - Scott Francis
63
64
  - Sean Stephens
64
65
  - Sebastian Kippe
66
+ - Sharang Dashputre
65
67
  - Spring MC
66
68
  - tbprojects
67
69
  - Tim Liner
68
70
  - Tony Lewis
69
71
  - Tom Crayford
72
+ - Tsu-Shiuan Lin
70
73
  - Vincent Zhu
71
74
  - Vladislav Shub
72
75
  - V Sreekanth
@@ -82,3 +85,4 @@ Resque Scheduler authors
82
85
  - malomalo
83
86
  - sawanoboly
84
87
  - serek
88
+ - iloveitaly
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  **ATTN**: This project uses [semantic versioning](http://semver.org/).
4
4
 
5
+ ## Unreleased
6
+
7
+ ## [4.5.0]
8
+ ### Added
9
+ - Support Ruby 3
10
+ - Add optional argument to `remove_schedule` to control reloading of the schedule
11
+
12
+ ### Fixed
13
+ - Fix XSS vulnerability on the `/delayed/search` page
14
+ - Ensure that jobs are directly created for jobs enqueued at `Time.now`
15
+ - Fix queuing to custom job queues in `enqueue_delayed_selection`
16
+ - Ensure `before_enqueue` and `after_enqueue` callbacks are called in all cases of queuing a job
17
+ - Fix redis error when running resque-scheduler without Redis
18
+
19
+ ### Changed
20
+ - Change CI from Travis to GitHub Actions
21
+ - Only allow rufus-scheduler versions lower than 3.7
22
+ - Update vagrant configuration
23
+
5
24
  ## [4.4.0] - 2019-04-11
6
25
  ### Added
7
26
  - Support Resque 2
@@ -14,7 +33,7 @@
14
33
  - Fix setting the `poll_sleep_amount` option
15
34
  - Escape class names in resque-web /delayed URLs
16
35
 
17
- ## Changed
36
+ ### Changed
18
37
  - Addressed redis-namespace deprecation warnings
19
38
  - Ensure `enqueue_in` args are Numeric, catching a common issue passing `ActiveSupport::Duration`
20
39
 
data/README.md CHANGED
@@ -2,10 +2,8 @@ resque-scheduler
2
2
  ================
3
3
 
4
4
 
5
- [![Dependency Status](https://gemnasium.com/badges/github.com/resque/resque-scheduler.svg)](https://gemnasium.com/github.com/resque/resque-scheduler)
6
5
  [![Gem Version](https://badge.fury.io/rb/resque-scheduler.svg)](https://badge.fury.io/rb/resque-scheduler)
7
- [![Build Status](https://travis-ci.org/resque/resque-scheduler.svg?branch=master)](https://travis-ci.org/resque/resque-scheduler)
8
- [![Windows Build Status](https://ci.appveyor.com/api/projects/status/sxvf2086v5j0absb/branch/master?svg=true)](https://ci.appveyor.com/project/resque/resque-scheduler/branch/master)
6
+ [![Ruby specs](https://github.com/resque/resque-scheduler/actions/workflows/ruby.yml/badge.svg)](https://github.com/resque/resque-scheduler/actions)
9
7
  [![Code Climate](https://codeclimate.com/github/resque/resque-scheduler/badges/gpa.svg)](https://codeclimate.com/github/resque/resque-scheduler)
10
8
 
11
9
  ### Description
@@ -641,7 +639,7 @@ that happens on Travis CI and Appveyor:
641
639
  bundle install
642
640
 
643
641
  # Make sure tests are green before you change stuff
644
- bundle exec rake
642
+ bundle exec rubocop && bundle exec rake
645
643
  # Change stuff
646
644
  # Repeat
647
645
  ```
data/Rakefile CHANGED
@@ -1,13 +1,9 @@
1
1
  # vim:fileencoding=utf-8
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rake/testtask'
4
- require 'rubocop/rake_task'
5
4
  require 'yard'
6
5
 
7
- task default: [:rubocop, :test] unless RUBY_PLATFORM =~ /java/
8
- task default: [:test] if RUBY_PLATFORM =~ /java/
9
-
10
- RuboCop::RakeTask.new
6
+ task default: :test
11
7
 
12
8
  Rake::TestTask.new do |t|
13
9
  t.libs << 'test'
@@ -24,7 +24,7 @@ module Resque
24
24
  def enqueue_at_with_queue(queue, timestamp, klass, *args)
25
25
  return false unless plugin.run_before_schedule_hooks(klass, *args)
26
26
 
27
- if Resque.inline? || timestamp.to_i < Time.now.to_i
27
+ if Resque.inline? || timestamp.to_i <= Time.now.to_i
28
28
  # Just create the job and let resque perform it right away with
29
29
  # inline. If the class is a custom job class, call self#scheduled
30
30
  # on it. This allows you to do things like
@@ -33,7 +33,7 @@ module Resque
33
33
  if klass.respond_to?(:scheduled)
34
34
  klass.scheduled(queue, klass.to_s, *args)
35
35
  else
36
- Resque::Job.create(queue, klass, *args)
36
+ Resque.enqueue_to(queue, klass, *args)
37
37
  end
38
38
  else
39
39
  delayed_push(timestamp, job_to_hash_with_queue(queue, klass, args))
@@ -64,9 +64,9 @@ module Resque
64
64
  end
65
65
 
66
66
  # Used internally to stuff the item into the schedule sorted list.
67
- # +timestamp+ can be either in seconds or a datetime object Insertion
68
- # if O(log(n)). Returns true if it's the first job to be scheduled at
69
- # that time, else false
67
+ # +timestamp+ can be either in seconds or a datetime object. The
68
+ # insertion time complexity is O(log(n)). Returns true if it's
69
+ # the first job to be scheduled at that time, else false.
70
70
  def delayed_push(timestamp, item)
71
71
  # First add this item to the list for this timestamp
72
72
  redis.rpush("delayed:#{timestamp.to_i}", encode(item))
@@ -88,6 +88,7 @@ module Resque
88
88
  end
89
89
 
90
90
  # Returns the size of the delayed queue schedule
91
+ # this does not represent the number of items in the queue to be scheduled
91
92
  def delayed_queue_schedule_size
92
93
  redis.zcard :delayed_queue_schedule
93
94
  end
@@ -149,6 +150,11 @@ module Resque
149
150
  remove_delayed_job(search)
150
151
  end
151
152
 
153
+ def remove_delayed_in_queue(klass, queue, *args)
154
+ search = encode(job_to_hash_with_queue(queue, klass, args))
155
+ remove_delayed_job(search)
156
+ end
157
+
152
158
  # Given an encoded item, enqueue it now
153
159
  def enqueue_delayed(klass, *args)
154
160
  hash = job_to_hash(klass, args)
@@ -157,6 +163,13 @@ module Resque
157
163
  end
158
164
  end
159
165
 
166
+ def enqueue_delayed_with_queue(klass, queue, *args)
167
+ hash = job_to_hash_with_queue(queue, klass, args)
168
+ remove_delayed_in_queue(klass, queue, *args).times do
169
+ Resque::Scheduler.enqueue_from_config(hash)
170
+ end
171
+ end
172
+
160
173
  # Given a block, remove jobs that return true from a block
161
174
  #
162
175
  # This allows for removal of delayed jobs that have arguments matching
@@ -181,7 +194,15 @@ module Resque
181
194
  found_jobs.reduce(0) do |sum, encoded_job|
182
195
  decoded_job = decode(encoded_job)
183
196
  klass = Util.constantize(decoded_job['class'])
184
- sum + enqueue_delayed(klass, *decoded_job['args'])
197
+ queue = decoded_job['queue']
198
+
199
+ if queue
200
+ jobs_queued = enqueue_delayed_with_queue(klass, queue, *decoded_job['args'])
201
+ else
202
+ jobs_queued = enqueue_delayed(klass, *decoded_job['args'])
203
+ end
204
+
205
+ jobs_queued + sum
185
206
  end
186
207
  end
187
208
 
@@ -271,6 +292,8 @@ module Resque
271
292
  { class: klass.to_s, args: args, queue: queue }
272
293
  end
273
294
 
295
+ # Removes a job from the queue, but not modify the timestamp schedule. This method
296
+ # will not effect the output of `delayed_queue_schedule_size`
274
297
  def remove_delayed_job(encoded_job)
275
298
  return 0 if Resque.inline?
276
299
 
@@ -283,6 +306,9 @@ module Resque
283
306
  end
284
307
  end
285
308
 
309
+ # timestamp key is not removed from the schedule, this is done later
310
+ # by the scheduler loop
311
+
286
312
  return 0 if replies.nil? || replies.empty?
287
313
  replies.each_slice(2).map(&:first).inject(:+)
288
314
  end
@@ -36,7 +36,7 @@ module Resque
36
36
  # :args can be any yaml which will be converted to a ruby literal and
37
37
  # passed in a params. (optional)
38
38
  #
39
- # :rails_envs is the list of envs where the job gets loaded. Envs are
39
+ # :rails_env is the list of envs where the job gets loaded. Envs are
40
40
  # comma separated (optional)
41
41
  #
42
42
  # :description is just that, a description of the job (optional). If
@@ -101,12 +101,13 @@ module Resque
101
101
  end
102
102
 
103
103
  # remove a given schedule by name
104
- def remove_schedule(name)
104
+ # Preventing a reload is optional and available to batch operations
105
+ def remove_schedule(name, reload = true)
105
106
  non_persistent_schedules.delete(name)
106
107
  redis.hdel(:persistent_schedules, name)
107
108
  redis.sadd(:schedules_changed, name)
108
109
 
109
- reload_schedule!
110
+ reload_schedule! if reload
110
111
  end
111
112
 
112
113
  private
@@ -46,7 +46,7 @@
46
46
  <td><%= h(show_job_arguments(job['args'])) if job && delayed_timestamp_size == 1 %></td>
47
47
  <td>
48
48
  <% if job %>
49
- <a href="<%=u URI("/delayed/jobs/#{URI.escape(job['class'])}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
49
+ <a href="<%=u URI("/delayed/jobs/#{CGI.escape(job['class'])}?args=" + CGI.escape(job['args'].to_json)) %>">All schedules</a>
50
50
  <% end %>
51
51
  </td>
52
52
  </tr>
@@ -1,5 +1,5 @@
1
1
  <form method="POST" action="<%= u 'delayed/search' %>">
2
- <input type='input' name='search' value="<%= params[:search] %>"/>
2
+ <input type='input' name='search' value="<%= h params[:search] %>"/>
3
3
  <input type='submit' value='Search'/>
4
4
  </form>
5
5
 
@@ -87,7 +87,7 @@ module Resque
87
87
  def delayed_jobs_klass
88
88
  begin
89
89
  klass = Resque::Scheduler::Util.constantize(params[:klass])
90
- @args = JSON.load(URI.decode(params[:args]))
90
+ @args = JSON.load(CGI.unescape(params[:args]))
91
91
  @timestamps = Resque.scheduled_at(klass, *@args)
92
92
  rescue
93
93
  @timestamps = []
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Resque
4
4
  module Scheduler
5
- VERSION = '4.4.0'.freeze
5
+ VERSION = '4.5.0'.freeze
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # vim:fileencoding=utf-8
2
2
 
3
+ require 'redis/errors'
3
4
  require 'rufus/scheduler'
4
5
  require_relative 'scheduler/configuration'
5
6
  require_relative 'scheduler/locking'
@@ -11,12 +11,14 @@ Gem::Specification.new do |spec|
11
11
  Simon Eskildsen
12
12
  Ryan Biesemeyer
13
13
  Dan Buch
14
+ Michael Bianco
14
15
  EOF
15
16
  spec.email = %w(
16
17
  bvandenbos@gmail.com
17
18
  sirup@sirupsen.com
18
19
  ryan@yaauie.com
19
20
  dan@meatballhat.com
21
+ mike@mikebian.co
20
22
  )
21
23
  spec.summary = 'Light weight job scheduling on top of Resque'
22
24
  spec.description = <<-DESCRIPTION
@@ -29,7 +31,7 @@ Gem::Specification.new do |spec|
29
31
 
30
32
  spec.files = `git ls-files -z`.split("\0").reject do |f|
31
33
  f.match(%r{^(test|spec|features|examples|bin|tasks)/}) ||
32
- f.match(/^(Vagrantfile|Gemfile\.lock|appveyor\.yml)/) ||
34
+ f.match(/^(Vagrantfile|Gemfile\.lock)/) ||
33
35
  f.match(/^\.(rubocop|simplecov|travis|vagrant|gitignore)/)
34
36
  end
35
37
  spec.bindir = 'exe'
@@ -48,6 +50,7 @@ Gem::Specification.new do |spec|
48
50
  spec.add_development_dependency 'test-unit'
49
51
  spec.add_development_dependency 'yard'
50
52
  spec.add_development_dependency 'tzinfo-data'
53
+ spec.add_development_dependency 'timecop'
51
54
 
52
55
  # We pin rubocop because new cops have a tendency to result in false-y
53
56
  # positives for new contributors, which is not a nice experience.
@@ -55,6 +58,7 @@ Gem::Specification.new do |spec|
55
58
 
56
59
  spec.add_runtime_dependency 'mono_logger', '~> 1.0'
57
60
  spec.add_runtime_dependency 'redis', '>= 3.3'
58
- spec.add_runtime_dependency 'resque', '>= 1.26'
59
- spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2'
61
+ spec.add_runtime_dependency 'resque', '>= 1.27'
62
+ # rufus-scheduler v3.7 causes a failure in test/multi_process_test.rb
63
+ spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2', '< 3.7'
60
64
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben VandenBos
8
8
  - Simon Eskildsen
9
9
  - Ryan Biesemeyer
10
10
  - Dan Buch
11
- autorequire:
11
+ - Michael Bianco
12
+ autorequire:
12
13
  bindir: exe
13
14
  cert_chain: []
14
- date: 2019-04-15 00:00:00.000000000 Z
15
+ date: 2021-09-28 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: bundler
@@ -181,6 +182,20 @@ dependencies:
181
182
  - - ">="
182
183
  - !ruby/object:Gem::Version
183
184
  version: '0'
185
+ - !ruby/object:Gem::Dependency
186
+ name: timecop
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ type: :development
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
184
199
  - !ruby/object:Gem::Dependency
185
200
  name: rubocop
186
201
  requirement: !ruby/object:Gem::Requirement
@@ -229,14 +244,14 @@ dependencies:
229
244
  requirements:
230
245
  - - ">="
231
246
  - !ruby/object:Gem::Version
232
- version: '1.26'
247
+ version: '1.27'
233
248
  type: :runtime
234
249
  prerelease: false
235
250
  version_requirements: !ruby/object:Gem::Requirement
236
251
  requirements:
237
252
  - - ">="
238
253
  - !ruby/object:Gem::Version
239
- version: '1.26'
254
+ version: '1.27'
240
255
  - !ruby/object:Gem::Dependency
241
256
  name: rufus-scheduler
242
257
  requirement: !ruby/object:Gem::Requirement
@@ -244,6 +259,9 @@ dependencies:
244
259
  - - "~>"
245
260
  - !ruby/object:Gem::Version
246
261
  version: '3.2'
262
+ - - "<"
263
+ - !ruby/object:Gem::Version
264
+ version: '3.7'
247
265
  type: :runtime
248
266
  prerelease: false
249
267
  version_requirements: !ruby/object:Gem::Requirement
@@ -251,6 +269,9 @@ dependencies:
251
269
  - - "~>"
252
270
  - !ruby/object:Gem::Version
253
271
  version: '3.2'
272
+ - - "<"
273
+ - !ruby/object:Gem::Version
274
+ version: '3.7'
254
275
  description: |2
255
276
  Light weight job scheduling on top of Resque.
256
277
  Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
@@ -260,11 +281,15 @@ email:
260
281
  - sirup@sirupsen.com
261
282
  - ryan@yaauie.com
262
283
  - dan@meatballhat.com
284
+ - mike@mikebian.co
263
285
  executables:
264
286
  - resque-scheduler
265
287
  extensions: []
266
288
  extra_rdoc_files: []
267
289
  files:
290
+ - ".github/dependabot.yml"
291
+ - ".github/workflows/rubocop.yml"
292
+ - ".github/workflows/ruby.yml"
268
293
  - AUTHORS.md
269
294
  - CHANGELOG.md
270
295
  - CODE_OF_CONDUCT.md
@@ -307,7 +332,7 @@ homepage: http://github.com/resque/resque-scheduler
307
332
  licenses:
308
333
  - MIT
309
334
  metadata: {}
310
- post_install_message:
335
+ post_install_message:
311
336
  rdoc_options: []
312
337
  require_paths:
313
338
  - lib
@@ -322,8 +347,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
347
  - !ruby/object:Gem::Version
323
348
  version: '0'
324
349
  requirements: []
325
- rubygems_version: 3.0.3
326
- signing_key:
350
+ rubygems_version: 3.1.6
351
+ signing_key:
327
352
  specification_version: 4
328
353
  summary: Light weight job scheduling on top of Resque
329
354
  test_files: []