resque-scheduler 4.10.1 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf0c6b96fa880ba5a817d63c04d9e17a070061c1f3cd7fe8b9ad6c91c2ffe016
4
- data.tar.gz: a01edeea347f025e87b7327a89a6fb509716ecea47b3cbe1a8c4eea0de08e3ff
3
+ metadata.gz: c4ecd4f957b7c3df8c89bc85ffb8951b5df6cc18b004379b29ebcfc3be982621
4
+ data.tar.gz: 7aacc351234c1f367d8b73cda10d43b97ff26e89a3319e0afa76b51abea70430
5
5
  SHA512:
6
- metadata.gz: 4a8facf77afaf21a8a39ebfab4cac5f42d97e743a353f70e43dfc3caa7f97da8ff6c9f868d57e9d7ba36c96f4b91cf4c66032e0803d69a1f2f04283e0fddac65
7
- data.tar.gz: 470bbd7ded28c0c4b62d3aa4bfa9b78c04066e3e430a124c6671c6dd336b3678ff3edab5266a72a705bb6cc8b65e1899b70891b4b06829dc417396d3aebaf8b1
6
+ metadata.gz: e668259967505827e06a40a83cb2e3b7c7c165df440c914c8e688c4d871594c46ac512ebb8a99856f4e3cf37f45625f5144bc6beeda1157c7b2d146eec9055cc
7
+ data.tar.gz: 32e7b921643fb62600d133db156c5f4c28d863a893a92d18ba1b1f7317b0371dd38cd11b0a1e2adcccfa211265f9d285b452d2e524d3637487e7c982c8563032
@@ -31,7 +31,7 @@ jobs:
31
31
 
32
32
  # Initializes the CodeQL tools for scanning.
33
33
  - name: Initialize CodeQL
34
- uses: github/codeql-action/init@v2
34
+ uses: github/codeql-action/init@v3
35
35
  with:
36
36
  languages: ${{ matrix.language }}
37
37
  # If you wish to specify custom queries, you can do so here or in a config file.
@@ -42,7 +42,7 @@ jobs:
42
42
  # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
43
43
  # If this step fails, then you should remove it and run the build manually (see below)
44
44
  - name: Autobuild
45
- uses: github/codeql-action/autobuild@v2
45
+ uses: github/codeql-action/autobuild@v3
46
46
 
47
47
  # ℹ️ Command-line programs to run using the OS shell.
48
48
  # 📚 https://git.io/JvXDl
@@ -56,4 +56,4 @@ jobs:
56
56
  # make release
57
57
 
58
58
  - name: Perform CodeQL Analysis
59
- uses: github/codeql-action/analyze@v2
59
+ uses: github/codeql-action/analyze@v3
@@ -27,6 +27,7 @@ jobs:
27
27
  - "3.0"
28
28
  - 3.1
29
29
  - 3.2
30
+ - 3.3
30
31
  resque-version:
31
32
  - "master"
32
33
  - "~> 2.4.0"
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  **ATTN**: This project uses [semantic versioning](http://semver.org/).
4
4
 
5
+ ## [4.10.3] - 2024-12-30
6
+ ### Added
7
+ * Expose timeout for lock via environment variable configuration by @pmm4654 in #786
8
+ * Add Ruby 3.3 to the CI matrix by @santiagorodriguez96 in #797
9
+
10
+ ### Fixed
11
+ * Fix schedule hooks when enqueuing configured job by @codealchemy in #792
12
+ * Fix undefined `header` method CI failures by @codealchemy in #793
13
+
14
+ ### Documentation
15
+ * Fix typo by @dijonkitchen in #789
16
+ * Fix links to generated docs by @dijonkitchen in #790
17
+
18
+ ### Security
19
+ * Bump github/codeql-action from 2 to 3 by @dependabot in #785
20
+
21
+ ## [4.10.2] - 2023-12-15
22
+ ### Fixed
23
+ * Finish fixing CVE-2022-44303, XSS in delayed_schedules by @PatrickTulskie in #783
24
+
5
25
  ## [4.10.1] - 2023-12-15
6
26
  ### Fixed
7
27
  * Fix json dump crasher with JSON 2.7.0+ by @PatrickTulskie in #781
data/README.md CHANGED
@@ -28,7 +28,7 @@ Resque.enqueue_at(5.days.from_now, SomeJob, argument) # runs a job at a specific
28
28
 
29
29
  This `README` covers what most people need to know. If you're looking
30
30
  for details on individual methods, you might want to try the
31
- [rdoc](http://rdoc.info/github/resque/resque-scheduler/master/frames).
31
+ [rubydoc](https://rubydoc.info/github/resque/resque-scheduler/master/frames).
32
32
 
33
33
  ### Installation
34
34
 
@@ -86,7 +86,7 @@ namespace :resque do
86
86
  # If your schedule already has +queue+ set for each job, you don't
87
87
  # need to require your jobs. This can be an advantage since it's
88
88
  # less code that resque-scheduler needs to know about. But in a small
89
- # project, it's usually easier to just include you job classes here.
89
+ # project, it's usually easier to just include your job classes here.
90
90
  # So, something like this:
91
91
  require 'jobs'
92
92
  end
@@ -15,7 +15,8 @@ module Resque
15
15
  quiet: 'QUIET',
16
16
  pidfile: 'PIDFILE',
17
17
  poll_sleep_amount: 'RESQUE_SCHEDULER_INTERVAL',
18
- verbose: 'VERBOSE'
18
+ verbose: 'VERBOSE',
19
+ lock_timeout: 'LOCK_TIMEOUT'
19
20
  }.freeze
20
21
 
21
22
  class Cli
@@ -80,6 +80,13 @@ module Resque
80
80
  Float(environment.fetch('RESQUE_SCHEDULER_INTERVAL', '5'))
81
81
  end
82
82
 
83
+ # Sets timeout for Resque::Scheduler::Lock::Base
84
+ attr_writer :lock_timeout
85
+
86
+ def lock_timeout
87
+ @lock_timeout ||= environment.fetch('LOCK_TIMEOUT', 60 * 3).to_i
88
+ end
89
+
83
90
  private
84
91
 
85
92
  # Copied from https://github.com/rails/rails/blob/main/activemodel/lib/active_model/type/boolean.rb#L17
@@ -22,24 +22,22 @@ module Resque
22
22
  # timestamp has passed. It respects Resque.inline option, by
23
23
  # creating the job right away instead of adding to the queue.
24
24
  def enqueue_at_with_queue(queue, timestamp, klass, *args)
25
- return false unless plugin.run_before_schedule_hooks(klass, *args)
26
-
27
- if Resque.inline? || timestamp.to_i <= Time.now.to_i
28
- # Just create the job and let resque perform it right away with
29
- # inline. If the class is a custom job class, call self#scheduled
30
- # on it. This allows you to do things like
31
- # Resque.enqueue_at(timestamp, CustomJobClass, :opt1 => val1).
32
- # Otherwise, pass off to Resque.
33
- if klass.respond_to?(:scheduled)
34
- klass.scheduled(queue, klass.to_s, *args)
25
+ plugin.process_schedule_hooks(klass, *args) do
26
+ if Resque.inline? || timestamp.to_i <= Time.now.to_i
27
+ # Just create the job and let resque perform it right away with
28
+ # inline. If the class is a custom job class, call self#scheduled
29
+ # on it. This allows you to do things like
30
+ # Resque.enqueue_at(timestamp, CustomJobClass, :opt1 => val1).
31
+ # Otherwise, pass off to Resque.
32
+ if klass.respond_to?(:scheduled)
33
+ klass.scheduled(queue, klass.to_s, *args)
34
+ else
35
+ Resque.enqueue_to(queue, klass, *args)
36
+ end
35
37
  else
36
- Resque.enqueue_to(queue, klass, *args)
38
+ delayed_push(timestamp, job_to_hash_with_queue(queue, klass, args))
37
39
  end
38
- else
39
- delayed_push(timestamp, job_to_hash_with_queue(queue, klass, args))
40
40
  end
41
-
42
- plugin.run_after_schedule_hooks(klass, *args)
43
41
  end
44
42
 
45
43
  # Identical to enqueue_at but takes number_of_seconds_from_now
@@ -54,6 +54,7 @@ module Resque
54
54
  at_exit { cleanup_pid_file }
55
55
  end
56
56
 
57
+ # rubocop:disable Metrics/AbcSize
57
58
  def setup_scheduler_configuration
58
59
  Resque::Scheduler.configure do |c|
59
60
  c.app_name = options[:app_name] if options.key?(:app_name)
@@ -66,6 +67,8 @@ module Resque
66
67
 
67
68
  c.logformat = options[:logformat] if options.key?(:logformat)
68
69
 
70
+ c.lock_timeout = options[:lock_timeout] if options.key?(:lock_timeout)
71
+
69
72
  if (psleep = options[:poll_sleep_amount]) && !psleep.nil?
70
73
  c.poll_sleep_amount = Float(psleep)
71
74
  end
@@ -73,6 +76,7 @@ module Resque
73
76
  c.verbose = !!options[:verbose] if options.key?(:verbose)
74
77
  end
75
78
  end
79
+ # rubocop:enable Metrics/AbcSize
76
80
 
77
81
  def cleanup_pid_file
78
82
  return unless pidfile_path
@@ -11,7 +11,7 @@ module Resque
11
11
  @key = key
12
12
 
13
13
  # 3 minute default timeout
14
- @timeout = options[:timeout] || 60 * 3
14
+ @timeout = options[:timeout] || Resque::Scheduler.lock_timeout
15
15
  end
16
16
 
17
17
  # Attempts to acquire the lock. Returns true if successfully acquired.
@@ -3,6 +3,15 @@
3
3
  module Resque
4
4
  module Scheduler
5
5
  module Plugin
6
+ def self.process_schedule_hooks(klass, *args)
7
+ # the documentation states that if any before_schedule hook returns
8
+ # false, the process should not be enqueued
9
+ return unless run_before_schedule_hooks(klass, *args)
10
+
11
+ yield
12
+ run_after_schedule_hooks(klass, *args)
13
+ end
14
+
6
15
  def self.hooks(job, pattern)
7
16
  job.methods.grep(/^#{pattern}/).sort
8
17
  end
@@ -1,4 +1,4 @@
1
- <h1>Delayed jobs scheduled for <%=h params[:klass] %> (<%= show_job_arguments(@args) %>)</h1>
1
+ <h1>Delayed jobs scheduled for <%=h params[:klass] %> (<%=h show_job_arguments(@args) %>)</h1>
2
2
 
3
3
  <table class='jobs'>
4
4
  <tr>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Resque
4
4
  module Scheduler
5
- VERSION = '4.10.1'.freeze
5
+ VERSION = '4.11.0'.freeze
6
6
  end
7
7
  end
@@ -331,17 +331,16 @@ module Resque
331
331
  # for non-existent classes (for example: running scheduler in
332
332
  # one app that schedules for another.
333
333
  if Class === klass
334
- Resque::Scheduler::Plugin.run_before_delayed_enqueue_hooks(
335
- klass, *params
336
- )
337
-
338
- # If the class is a custom job class, call self#scheduled on it.
339
- # This allows you to do things like Resque.enqueue_at(timestamp,
340
- # CustomJobClass). Otherwise, pass off to Resque.
341
- if klass.respond_to?(:scheduled)
342
- klass.scheduled(queue, klass_name, *params)
343
- else
344
- Resque.enqueue_to(queue, klass, *params)
334
+ Resque::Scheduler::Plugin.process_schedule_hooks(klass, *params) do
335
+ Resque::Scheduler::Plugin.run_before_delayed_enqueue_hooks(klass, *params)
336
+ # If the class is a custom job class, call self#scheduled on it.
337
+ # This allows you to do things like Resque.enqueue_at(timestamp,
338
+ # CustomJobClass). Otherwise, pass off to Resque.
339
+ if klass.respond_to?(:scheduled)
340
+ klass.scheduled(queue, klass_name, *params)
341
+ else
342
+ Resque.enqueue_to(queue, klass, *params)
343
+ end
345
344
  end
346
345
  else
347
346
  # This will not run the before_hooks in rescue, but will at least
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.1
4
+ version: 4.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben VandenBos
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2023-12-15 00:00:00.000000000 Z
16
+ date: 2024-12-30 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler