sidekiq-scheduler 4.0.3 → 5.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +46 -39
- data/lib/sidekiq-scheduler/config.rb +80 -0
- data/lib/sidekiq-scheduler/manager.rb +15 -24
- data/lib/sidekiq-scheduler/redis_manager.rb +3 -3
- data/lib/sidekiq-scheduler/scheduler.rb +21 -15
- data/lib/sidekiq-scheduler/sidekiq_adapter.rb +80 -0
- data/lib/sidekiq-scheduler/version.rb +1 -1
- data/lib/sidekiq-scheduler/web.rb +1 -1
- data/lib/sidekiq-scheduler.rb +6 -17
- metadata +31 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adc6f05c8d6f36cedff6c3fb051e7314581cbe1b4e460fe3227ec7c2e11cf842
|
4
|
+
data.tar.gz: d88174e3e2bacf2b4571f9b5a4d758ff5e30e456039dd967fbf1a2ff3440b155
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41792a0657385179077cda82953df1dfc304af70f80a50355803b5a3b5b33de32e764e043b79874216e2fbbc38997e6fd9dde1ba8a9d3359019ccc86f9ca52e
|
7
|
+
data.tar.gz: 392629ec1306d5ea3d3af1b5a20c23756696d447ee5cee618b5f16b322f0def210c269331248956e43758d6b653257ef123bd73af48de66e49eb019a53b477db
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# 5.0.0.beta1
|
2
|
+
|
3
|
+
- [**BREAKING CHANGE**] Moves all sidekiq-scheduler config options under the `scheduler` key in the `sidekiq.yml` file [#412](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/412)
|
4
|
+
- If you're migrating from v4 to v5, any `sidekiq-scheduler` config you may have in your `sidekiq.yml` should be moved under the `scheduler` key.
|
5
|
+
- See [#412](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/412) to see which are the config options that you need to move under the `scheduler` key.
|
6
|
+
|
7
|
+
- [**BREAKING CHANGE**] Drop support for EOL Ruby & Sidekiq versions (Ruby: `2.5.x` & `2.6.x`; Sidekiq: `4.x` & `5.x`) [#411](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/411)
|
8
|
+
|
9
|
+
- [**FIX**] Add support for Sidekiq 7 [#410](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/410)
|
10
|
+
|
11
|
+
|
1
12
|
# 4.0.3
|
2
13
|
|
3
14
|
- [**GH Actions**] Add dependabot for GitHub Actions [#390](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/390)
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
`sidekiq-scheduler` is an extension to [Sidekiq](http://github.com/mperham/sidekiq) that
|
19
19
|
pushes jobs in a scheduled way, mimicking cron utility.
|
20
20
|
|
21
|
-
__Note:__ Current branch contains work of the
|
21
|
+
__Note:__ Current branch contains work of the upcoming v5 release, if you are looking for version 2.2.\*, 3.\*, or 4.\*, go to [2.2-stable branch](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/2.2-stable) / [v3-stable](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/v3-stable) / [v4-stable](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/v4-stable).
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -48,10 +48,11 @@ end
|
|
48
48
|
``` yaml
|
49
49
|
# config/sidekiq.yml
|
50
50
|
|
51
|
-
:
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
:scheduler:
|
52
|
+
:schedule:
|
53
|
+
hello_world:
|
54
|
+
cron: '0 * * * * *' # Runs once per minute
|
55
|
+
class: HelloWorld
|
55
56
|
```
|
56
57
|
|
57
58
|
Run sidekiq:
|
@@ -83,40 +84,41 @@ Configuration options are placed inside `sidekiq.yml` config file.
|
|
83
84
|
Available options are:
|
84
85
|
|
85
86
|
``` yaml
|
86
|
-
:dynamic: <if true the schedule can be modified in runtime [false by default]>
|
87
|
-
:dynamic_every: <if dynamic is true, the schedule is reloaded every interval [5s by default]>
|
88
|
-
:enabled: <enables scheduler if true [true by default]>
|
89
87
|
:scheduler:
|
88
|
+
:dynamic: <if true the schedule can be modified in runtime [false by default]>
|
89
|
+
:dynamic_every: <if dynamic is true, the schedule is reloaded every interval [5s by default]>
|
90
|
+
:enabled: <enables scheduler if true [true by default]>
|
90
91
|
:listened_queues_only: <push jobs whose queue is being listened by sidekiq [false by default]>
|
91
|
-
:rufus_scheduler_options: <Set custom options for rufus scheduler, like max_work_threads [{} by default]>
|
92
|
+
:rufus_scheduler_options: <Set custom options for rufus scheduler, like max_work_threads [{} by default]>
|
92
93
|
```
|
93
94
|
|
94
95
|
## Schedule configuration
|
95
96
|
|
96
|
-
The schedule is configured through the `:schedule` config entry in the sidekiq config file:
|
97
|
+
The schedule is configured through the `:scheduler:` -> `:schedule` config entry in the sidekiq config file:
|
97
98
|
|
98
99
|
``` yaml
|
99
|
-
:
|
100
|
-
|
101
|
-
|
100
|
+
:scheduler:
|
101
|
+
:schedule:
|
102
|
+
CancelAbandonedOrders:
|
103
|
+
cron: '0 */5 * * * *' # Runs when second = 0, every 5 minutes
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
+
queue_documents_for_indexing:
|
106
|
+
cron: '0 0 * * * *' # Runs every hour
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
# By default the job name will be taken as worker class name.
|
109
|
+
# If you want to have a different job name and class name, provide the 'class' option
|
110
|
+
class: QueueDocuments
|
109
111
|
|
110
|
-
|
111
|
-
|
112
|
-
|
112
|
+
queue: slow
|
113
|
+
args: ['*.pdf']
|
114
|
+
description: "This job queues pdf content for indexing in solr"
|
113
115
|
|
114
|
-
|
115
|
-
|
116
|
-
|
116
|
+
# Enable the `metadata` argument which will pass a Hash containing the schedule metadata
|
117
|
+
# as the last argument of the `perform` method. `false` by default.
|
118
|
+
include_metadata: true
|
117
119
|
|
118
|
-
|
119
|
-
|
120
|
+
# Enable / disable a job. All jobs are enabled by default.
|
121
|
+
enabled: true
|
120
122
|
```
|
121
123
|
|
122
124
|
### Schedule metadata
|
@@ -157,9 +159,10 @@ Cron, every, and interval types push jobs into sidekiq in a recurrent manner.
|
|
157
159
|
`cron` follows the same pattern as cron utility, with seconds resolution.
|
158
160
|
|
159
161
|
``` yaml
|
160
|
-
:
|
161
|
-
|
162
|
-
|
162
|
+
:scheduler:
|
163
|
+
:schedule:
|
164
|
+
HelloWorld:
|
165
|
+
cron: '0 * * * * *' # Runs when second = 0
|
163
166
|
```
|
164
167
|
|
165
168
|
`every` triggers following a given frequency:
|
@@ -250,7 +253,8 @@ When `:dynamic` flag is set to `true`, schedule changes are loaded every 5 secon
|
|
250
253
|
|
251
254
|
``` yaml
|
252
255
|
# config/sidekiq.yml
|
253
|
-
:
|
256
|
+
:scheduler:
|
257
|
+
:dynamic: true
|
254
258
|
```
|
255
259
|
|
256
260
|
If `:dynamic` flag is set to `false`, you'll have to reload the schedule manually in sidekiq
|
@@ -299,8 +303,9 @@ You can also override the thread pool size in Rufus Scheduler by setting the fol
|
|
299
303
|
---
|
300
304
|
...
|
301
305
|
|
302
|
-
|
303
|
-
|
306
|
+
:scheduler:
|
307
|
+
rufus_scheduler_options:
|
308
|
+
max_work_threads: 5
|
304
309
|
|
305
310
|
...
|
306
311
|
```
|
@@ -386,12 +391,13 @@ Say you have one process with the schedule:
|
|
386
391
|
|
387
392
|
:queues:
|
388
393
|
- default
|
389
|
-
:
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
394
|
+
:scheduler:
|
395
|
+
:schedule:
|
396
|
+
do_something_every_minute:
|
397
|
+
class: DoSomethingJob
|
398
|
+
args: matey
|
399
|
+
queue: :scheduler
|
400
|
+
cron: '0 * * * * * America/Los_Angeles'
|
395
401
|
```
|
396
402
|
|
397
403
|
And a separate separate configured process without one:
|
@@ -401,7 +407,8 @@ And a separate separate configured process without one:
|
|
401
407
|
- scheduler
|
402
408
|
|
403
409
|
## NOTE Disable the Scheduler
|
404
|
-
:
|
410
|
+
:scheduler:
|
411
|
+
:enabled: false
|
405
412
|
```
|
406
413
|
|
407
414
|
### Details
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module SidekiqScheduler
|
2
|
+
class Config
|
3
|
+
# We have to set the default as nil because the scheduler could be instantiated without
|
4
|
+
# passing the sidekiq config, and in those scenarios we don't want to fail
|
5
|
+
def initialize(sidekiq_config: nil, without_defaults: false)
|
6
|
+
@sidekiq_config = sidekiq_config
|
7
|
+
@scheduler_config = fetch_scheduler_config(sidekiq_config, without_defaults)
|
8
|
+
end
|
9
|
+
|
10
|
+
def enabled?
|
11
|
+
scheduler_config[:enabled]
|
12
|
+
end
|
13
|
+
|
14
|
+
def enabled=(value)
|
15
|
+
scheduler_config[:enabled] = value
|
16
|
+
end
|
17
|
+
|
18
|
+
def dynamic?
|
19
|
+
scheduler_config[:dynamic]
|
20
|
+
end
|
21
|
+
|
22
|
+
def dynamic=(value)
|
23
|
+
scheduler_config[:dynamic] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def dynamic_every?
|
27
|
+
scheduler_config[:dynamic_every]
|
28
|
+
end
|
29
|
+
|
30
|
+
def dynamic_every=(value)
|
31
|
+
scheduler_config[:dynamic_every] = value
|
32
|
+
end
|
33
|
+
|
34
|
+
def schedule
|
35
|
+
scheduler_config[:schedule]
|
36
|
+
end
|
37
|
+
|
38
|
+
def schedule=(value)
|
39
|
+
scheduler_config[:schedule] = value
|
40
|
+
end
|
41
|
+
|
42
|
+
def listened_queues_only?
|
43
|
+
scheduler_config[:listened_queues_only]
|
44
|
+
end
|
45
|
+
|
46
|
+
def listened_queues_only=(value)
|
47
|
+
scheduler_config[:listened_queues_only] = value
|
48
|
+
end
|
49
|
+
|
50
|
+
def rufus_scheduler_options
|
51
|
+
scheduler_config[:rufus_scheduler_options]
|
52
|
+
end
|
53
|
+
|
54
|
+
def rufus_scheduler_options=(value)
|
55
|
+
scheduler_config[:rufus_scheduler_options] = value
|
56
|
+
end
|
57
|
+
|
58
|
+
def sidekiq_queues
|
59
|
+
SidekiqScheduler::SidekiqAdapter.sidekiq_queues(sidekiq_config)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
attr_reader :scheduler_config
|
65
|
+
attr_reader :sidekiq_config
|
66
|
+
|
67
|
+
DEFAULT_OPTIONS = {
|
68
|
+
enabled: true,
|
69
|
+
dynamic: false,
|
70
|
+
dynamic_every: '5s',
|
71
|
+
schedule: {},
|
72
|
+
rufus_scheduler_options: {}
|
73
|
+
}.freeze
|
74
|
+
|
75
|
+
def fetch_scheduler_config(sidekiq_config, without_defaults)
|
76
|
+
conf = SidekiqScheduler::SidekiqAdapter.fetch_scheduler_config_from_sidekiq(sidekiq_config)
|
77
|
+
without_defaults ? conf : DEFAULT_OPTIONS.merge(conf)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -10,19 +10,12 @@ module SidekiqScheduler
|
|
10
10
|
# from Redis onto the work queues
|
11
11
|
#
|
12
12
|
class Manager
|
13
|
-
|
14
|
-
|
15
|
-
dynamic: false,
|
16
|
-
dynamic_every: '5s',
|
17
|
-
schedule: {}
|
18
|
-
}
|
13
|
+
def initialize(config)
|
14
|
+
set_current_scheduler_options(config)
|
19
15
|
|
20
|
-
|
21
|
-
scheduler_options = load_scheduler_options(options)
|
22
|
-
|
23
|
-
@scheduler_instance = SidekiqScheduler::Scheduler.new(scheduler_options)
|
16
|
+
@scheduler_instance = SidekiqScheduler::Scheduler.new(config)
|
24
17
|
SidekiqScheduler::Scheduler.instance = @scheduler_instance
|
25
|
-
Sidekiq.schedule =
|
18
|
+
Sidekiq.schedule = config.schedule if @scheduler_instance.enabled
|
26
19
|
end
|
27
20
|
|
28
21
|
def stop
|
@@ -35,19 +28,17 @@ module SidekiqScheduler
|
|
35
28
|
|
36
29
|
private
|
37
30
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
scheduler_options.merge(current_options)
|
31
|
+
def set_current_scheduler_options(config)
|
32
|
+
enabled = SidekiqScheduler::Scheduler.enabled
|
33
|
+
dynamic = SidekiqScheduler::Scheduler.dynamic
|
34
|
+
dynamic_every = SidekiqScheduler::Scheduler.dynamic_every
|
35
|
+
listened_queues_only = SidekiqScheduler::Scheduler.listened_queues_only
|
36
|
+
|
37
|
+
config.enabled = enabled unless enabled.nil?
|
38
|
+
config.dynamic = dynamic unless dynamic.nil?
|
39
|
+
config.dynamic_every = dynamic_every unless dynamic_every.nil?
|
40
|
+
config.schedule = Sidekiq.schedule if Sidekiq.schedule.present?
|
41
|
+
config.listened_queues_only = listened_queues_only unless listened_queues_only.nil?
|
51
42
|
end
|
52
43
|
end
|
53
44
|
end
|
@@ -96,7 +96,7 @@ module SidekiqScheduler
|
|
96
96
|
#
|
97
97
|
# @return [Boolean] true if the schedules key is set, false otherwise
|
98
98
|
def self.schedule_exist?
|
99
|
-
|
99
|
+
SidekiqScheduler::SidekiqAdapter.redis_key_exists?(schedules_key)
|
100
100
|
end
|
101
101
|
|
102
102
|
# Returns all the schedule changes for a given time range.
|
@@ -136,7 +136,7 @@ module SidekiqScheduler
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
registered
|
139
|
+
registered.instance_of?(Integer) ? (registered > 0) : registered
|
140
140
|
end
|
141
141
|
|
142
142
|
# Removes instances of the job older than 24 hours
|
@@ -210,7 +210,7 @@ module SidekiqScheduler
|
|
210
210
|
end
|
211
211
|
|
212
212
|
private
|
213
|
-
|
213
|
+
|
214
214
|
# Returns the value of a Redis stored hash field
|
215
215
|
#
|
216
216
|
# @param [String] hash_key The key name of the hash
|
@@ -2,6 +2,7 @@ require 'rufus/scheduler'
|
|
2
2
|
require 'json'
|
3
3
|
require 'sidekiq-scheduler/rufus_utils'
|
4
4
|
require 'sidekiq-scheduler/redis_manager'
|
5
|
+
require 'sidekiq-scheduler/config'
|
5
6
|
|
6
7
|
module SidekiqScheduler
|
7
8
|
class Scheduler
|
@@ -10,6 +11,15 @@ module SidekiqScheduler
|
|
10
11
|
alias_method :params, :opts
|
11
12
|
end
|
12
13
|
|
14
|
+
# TODO: Can we remove those attr_accessor's? If we need to keep them, we should
|
15
|
+
# update those values on the config object instead of just here in the scheduler.
|
16
|
+
# That's why we need to do what we do in the set_current_scheduler_options (not
|
17
|
+
# saying we will have to do it somehow still)
|
18
|
+
#
|
19
|
+
# NOTE: ^ Keeping this TODO here for now, in a future version of this project
|
20
|
+
# we will remove those attr acessors and use only our config object. For now,
|
21
|
+
# let's keep as it is.
|
22
|
+
|
13
23
|
# Set to enable or disable the scheduler.
|
14
24
|
attr_accessor :enabled
|
15
25
|
|
@@ -41,12 +51,14 @@ module SidekiqScheduler
|
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
44
|
-
def initialize(
|
45
|
-
|
46
|
-
|
47
|
-
self.
|
48
|
-
self.
|
49
|
-
self.
|
54
|
+
def initialize(config = SidekiqScheduler::Config.new(without_defaults: true))
|
55
|
+
@scheduler_config = config
|
56
|
+
|
57
|
+
self.enabled = config.enabled?
|
58
|
+
self.dynamic = config.dynamic?
|
59
|
+
self.dynamic_every = config.dynamic_every?
|
60
|
+
self.listened_queues_only = config.listened_queues_only?
|
61
|
+
self.rufus_scheduler_options = config.rufus_scheduler_options
|
50
62
|
end
|
51
63
|
|
52
64
|
# the Rufus::Scheduler jobs that are scheduled
|
@@ -82,7 +94,7 @@ module SidekiqScheduler
|
|
82
94
|
Sidekiq.logger.info 'Schedule empty! Set Sidekiq.schedule' if Sidekiq.schedule.empty?
|
83
95
|
|
84
96
|
@scheduled_jobs = {}
|
85
|
-
queues = sidekiq_queues
|
97
|
+
queues = scheduler_config.sidekiq_queues
|
86
98
|
|
87
99
|
Sidekiq.schedule.each do |name, config|
|
88
100
|
if !listened_queues_only || enabled_queue?(config['queue'].to_s, queues)
|
@@ -238,6 +250,8 @@ module SidekiqScheduler
|
|
238
250
|
|
239
251
|
private
|
240
252
|
|
253
|
+
attr_reader :scheduler_config
|
254
|
+
|
241
255
|
def new_job(name, interval_type, config, schedule, options)
|
242
256
|
options = options.merge({ :job => true, :tags => [name] })
|
243
257
|
|
@@ -291,14 +305,6 @@ module SidekiqScheduler
|
|
291
305
|
end
|
292
306
|
end
|
293
307
|
|
294
|
-
def sidekiq_queues
|
295
|
-
if SIDEKIQ_GTE_6_5_0
|
296
|
-
Sidekiq[:queues].map(&:to_s)
|
297
|
-
else
|
298
|
-
Sidekiq.options[:queues].map(&:to_s)
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
308
|
# Returns true if a job's queue is included in the array of queues
|
303
309
|
#
|
304
310
|
# If queues are empty, returns true.
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module SidekiqScheduler
|
2
|
+
class OptionNotSupportedAnymore < StandardError; end
|
3
|
+
|
4
|
+
class SidekiqAdapter
|
5
|
+
SIDEKIQ_GTE_6_5_0 = Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
|
6
|
+
SIDEKIQ_GTE_7_0_0 = Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('7.0.0')
|
7
|
+
|
8
|
+
def self.fetch_scheduler_config_from_sidekiq(sidekiq_config)
|
9
|
+
return {} if sidekiq_config.nil?
|
10
|
+
|
11
|
+
check_using_old_sidekiq_scheduler_config!(sidekiq_config)
|
12
|
+
|
13
|
+
if SIDEKIQ_GTE_6_5_0
|
14
|
+
sidekiq_config.fetch(:scheduler, {})
|
15
|
+
else
|
16
|
+
sidekiq_config.options.fetch(:scheduler, {})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.check_using_old_sidekiq_scheduler_config!(sidekiq_config)
|
21
|
+
%i[enabled dynamic dynamic_every schedule listened_queues_only rufus_scheduler_options].each do |option|
|
22
|
+
if SIDEKIQ_GTE_7_0_0
|
23
|
+
if sidekiq_config.key?(option)
|
24
|
+
raise OptionNotSupportedAnymore, ":#{option} option should be under the :scheduler: key"
|
25
|
+
end
|
26
|
+
elsif SIDEKIQ_GTE_6_5_0
|
27
|
+
unless sidekiq_config[option].nil?
|
28
|
+
raise OptionNotSupportedAnymore, ":#{option} option should be under the :scheduler: key"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
if sidekiq_config.options.key?(option)
|
32
|
+
raise OptionNotSupportedAnymore, ":#{option} option should be under the :scheduler: key"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.start_schedule_manager(sidekiq_config:, schedule_manager:)
|
39
|
+
if SIDEKIQ_GTE_6_5_0
|
40
|
+
sidekiq_config[:schedule_manager] = schedule_manager
|
41
|
+
sidekiq_config[:schedule_manager].start
|
42
|
+
else
|
43
|
+
sidekiq_config.options[:schedule_manager] = schedule_manager
|
44
|
+
sidekiq_config.options[:schedule_manager].start
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.stop_schedule_manager(sidekiq_config:)
|
49
|
+
if SIDEKIQ_GTE_6_5_0
|
50
|
+
sidekiq_config[:schedule_manager].stop
|
51
|
+
else
|
52
|
+
sidekiq_config.options[:schedule_manager].stop
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.sidekiq_queues(sidekiq_config)
|
57
|
+
if SIDEKIQ_GTE_7_0_0
|
58
|
+
if sidekiq_config.present?
|
59
|
+
sidekiq_config.queues.map(&:to_s)
|
60
|
+
else
|
61
|
+
Sidekiq.instance_variable_get(:@config).queues.map(&:to_s)
|
62
|
+
end
|
63
|
+
elsif SIDEKIQ_GTE_6_5_0
|
64
|
+
Sidekiq[:queues].map(&:to_s)
|
65
|
+
else
|
66
|
+
Sidekiq.options[:queues].map(&:to_s)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.redis_key_exists?(key_name)
|
71
|
+
Sidekiq.redis do |r|
|
72
|
+
if SIDEKIQ_GTE_7_0_0
|
73
|
+
r.exists(key_name) > 0
|
74
|
+
else
|
75
|
+
r.exists?(key_name)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -3,7 +3,7 @@ require 'sidekiq-scheduler'
|
|
3
3
|
require_relative 'job_presenter'
|
4
4
|
|
5
5
|
module SidekiqScheduler
|
6
|
-
# Hook into *Sidekiq::Web*
|
6
|
+
# Hook into *Sidekiq::Web* app which adds a new '/recurring-jobs' page
|
7
7
|
|
8
8
|
module Web
|
9
9
|
VIEW_PATH = File.expand_path('../../../web/views', __FILE__)
|
data/lib/sidekiq-scheduler.rb
CHANGED
@@ -5,9 +5,9 @@ require_relative 'sidekiq/scheduler'
|
|
5
5
|
require_relative 'sidekiq-scheduler/version'
|
6
6
|
require_relative 'sidekiq-scheduler/manager'
|
7
7
|
require_relative 'sidekiq-scheduler/redis_manager'
|
8
|
+
require_relative 'sidekiq-scheduler/config'
|
8
9
|
require_relative 'sidekiq-scheduler/extensions/schedule'
|
9
|
-
|
10
|
-
SIDEKIQ_GTE_6_5_0 = Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
|
10
|
+
require_relative 'sidekiq-scheduler/sidekiq_adapter'
|
11
11
|
|
12
12
|
Sidekiq.configure_server do |config|
|
13
13
|
|
@@ -15,25 +15,14 @@ Sidekiq.configure_server do |config|
|
|
15
15
|
# schedules_changed's type was changed from SET to ZSET, so we remove old versions at startup
|
16
16
|
SidekiqScheduler::RedisManager.clean_schedules_changed
|
17
17
|
|
18
|
-
|
19
|
-
config_options = SIDEKIQ_GTE_6_5_0 ? Sidekiq.instance_variable_get(:@config) : config.options
|
18
|
+
scheduler_config = SidekiqScheduler::Config.new(sidekiq_config: config)
|
20
19
|
|
21
|
-
schedule_manager = SidekiqScheduler::Manager.new(
|
22
|
-
|
23
|
-
config[:schedule_manager] = schedule_manager
|
24
|
-
config[:schedule_manager].start
|
25
|
-
else
|
26
|
-
config.options[:schedule_manager] = schedule_manager
|
27
|
-
config.options[:schedule_manager].start
|
28
|
-
end
|
20
|
+
schedule_manager = SidekiqScheduler::Manager.new(scheduler_config)
|
21
|
+
SidekiqScheduler::SidekiqAdapter.start_schedule_manager(sidekiq_config: config, schedule_manager: schedule_manager)
|
29
22
|
end
|
30
23
|
|
31
24
|
config.on(:quiet) do
|
32
|
-
|
33
|
-
config[:schedule_manager].stop
|
34
|
-
else
|
35
|
-
config.options[:schedule_manager].stop
|
36
|
-
end
|
25
|
+
SidekiqScheduler::SidekiqAdapter.stop_schedule_manager(sidekiq_config: config)
|
37
26
|
end
|
38
27
|
|
39
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morton Jonuschat
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sidekiq
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '4'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '8'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,21 +31,7 @@ dependencies:
|
|
31
31
|
version: '4'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: redis
|
37
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: 4.2.0
|
42
|
-
type: :runtime
|
43
|
-
prerelease: false
|
44
|
-
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 4.2.0
|
34
|
+
version: '8'
|
49
35
|
- !ruby/object:Gem::Dependency
|
50
36
|
name: rufus-scheduler
|
51
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,14 +66,14 @@ dependencies:
|
|
80
66
|
requirements:
|
81
67
|
- - "~>"
|
82
68
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
69
|
+
version: '12.0'
|
84
70
|
type: :development
|
85
71
|
prerelease: false
|
86
72
|
version_requirements: !ruby/object:Gem::Requirement
|
87
73
|
requirements:
|
88
74
|
- - "~>"
|
89
75
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
76
|
+
version: '12.0'
|
91
77
|
- !ruby/object:Gem::Dependency
|
92
78
|
name: timecop
|
93
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +102,20 @@ dependencies:
|
|
116
102
|
- - ">="
|
117
103
|
- !ruby/object:Gem::Version
|
118
104
|
version: '0'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: redis
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 4.2.0
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 4.2.0
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: rspec
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,19 +187,19 @@ dependencies:
|
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
- !ruby/object:Gem::Dependency
|
190
|
-
name:
|
190
|
+
name: rack
|
191
191
|
requirement: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
|
-
- - "
|
193
|
+
- - "<"
|
194
194
|
- !ruby/object:Gem::Version
|
195
|
-
version: '
|
195
|
+
version: '3'
|
196
196
|
type: :development
|
197
197
|
prerelease: false
|
198
198
|
version_requirements: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- - "
|
200
|
+
- - "<"
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: '
|
202
|
+
version: '3'
|
203
203
|
description: Light weight job scheduling extension for Sidekiq that adds support for
|
204
204
|
queueing jobs in a recurring way.
|
205
205
|
email:
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- README.md
|
215
215
|
- Rakefile
|
216
216
|
- lib/sidekiq-scheduler.rb
|
217
|
+
- lib/sidekiq-scheduler/config.rb
|
217
218
|
- lib/sidekiq-scheduler/extensions/schedule.rb
|
218
219
|
- lib/sidekiq-scheduler/extensions/web.rb
|
219
220
|
- lib/sidekiq-scheduler/job_presenter.rb
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- lib/sidekiq-scheduler/rufus_utils.rb
|
223
224
|
- lib/sidekiq-scheduler/schedule.rb
|
224
225
|
- lib/sidekiq-scheduler/scheduler.rb
|
226
|
+
- lib/sidekiq-scheduler/sidekiq_adapter.rb
|
225
227
|
- lib/sidekiq-scheduler/utils.rb
|
226
228
|
- lib/sidekiq-scheduler/version.rb
|
227
229
|
- lib/sidekiq-scheduler/web.rb
|
@@ -253,14 +255,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
255
|
requirements:
|
254
256
|
- - ">="
|
255
257
|
- !ruby/object:Gem::Version
|
256
|
-
version: '2.
|
258
|
+
version: '2.7'
|
257
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
260
|
requirements:
|
259
|
-
- - "
|
261
|
+
- - ">"
|
260
262
|
- !ruby/object:Gem::Version
|
261
|
-
version:
|
263
|
+
version: 1.3.1
|
262
264
|
requirements: []
|
263
|
-
rubygems_version: 3.
|
265
|
+
rubygems_version: 3.2.33
|
264
266
|
signing_key:
|
265
267
|
specification_version: 4
|
266
268
|
summary: Light weight job scheduling extension for Sidekiq
|