sidekiq-scheduler 4.0.1 → 4.0.3

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
  SHA256:
3
- metadata.gz: 1106fa4b63b6bb5d15759e20a1bdfb617a4fe53adb3c8041455e80aee14a2bde
4
- data.tar.gz: f4f954b22fa9f6f36ff9fe664a962ab40b75b279ebd292fb64e06f917e3b050a
3
+ metadata.gz: c16869144651f4193112eb896e092d382af94340b373f11ba92cefbdcc8fa875
4
+ data.tar.gz: 00b8efaca9cfcfe0379b633f5ca8aa215fa1f382fcd86fd29910b7ac64e6db7f
5
5
  SHA512:
6
- metadata.gz: 39c7aedbbf5260a184c7507f5fa0f84c0178a45465ff662f253fe23a1828d9d33e457ce9c5f1abbfd6a6d0d4a4d9915b4422dcef80f8d89e4856c80333fbeff1
7
- data.tar.gz: c04e172346a179aea9d22ee45d9a4546e44d241016ce012063d72005e6e9d10ff99364e7b34b11311c339c0a5894a737dea01fb16783883a2aa37b52f504ddd4
6
+ metadata.gz: 5afc74e4fa2a54d2b00e9d1a1343f64f242d217bee9c0ec170a4fd502cc7d7233598123c769034b7ad830c75eecab1f9aa99513bcac0d42bcaef91d771ddf7d0
7
+ data.tar.gz: 2e096c861063f78ce359807fd6e58477ca3e8489d645dca3a5c188e5713ed07b61392ddc96ec0d0eb6f5c0c6b3da91aec3c9cf3e27dcd9f4094f37b3185352b1
data/CHANGELOG.md CHANGED
@@ -1,20 +1,34 @@
1
+ # 4.0.3
2
+
3
+ - [**GH Actions**] Add dependabot for GitHub Actions [#390](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/390)
4
+ - [**ENHANCEMENT**] Add «Enable all» and «Disable all» buttons [#398](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/398)
5
+ - [**ENHANCEMENT**] Allow for multiple applications to share a Redis DB [#401](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/401)
6
+ - [**FIX**] Fix metadata for Sidekiq strict_args! [#403](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/403)
7
+ - [**FIX**] Redis 5.0 compatibility [#404](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/404)
8
+ - [**FIX**] Fix the constantize method [#408](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/408)
9
+
10
+ # 4.0.2
11
+
12
+ - [**FIX**] Fix sidekiq deprecation warning when Sidekiq 6.5+ [#385](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/385)
13
+ - [**FIX**] Fix `#print_schedule` calling a method that doesn't exist in rufus scheduler [#388](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/388)
14
+
1
15
  # 4.0.1
2
16
 
3
- - [**FIX**] Add support for sidekiq 6.5 [#382](https://github.com/moove-it/sidekiq-scheduler/pull/382)
17
+ - [**FIX**] Add support for sidekiq 6.5 [#382](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/382)
4
18
 
5
19
  # 4.0.0
6
20
 
7
- - [**FIX**] Fix CSS not loading on Rails app when Sidekiq < 6 [#377](https://github.com/moove-it/sidekiq-scheduler/pull/377)
8
- - [**BREAKING CHANGE**] Drop support for Sidekiq 3 [f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1](https://github.com/moove-it/sidekiq-scheduler/commit/f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1)
21
+ - [**FIX**] Fix CSS not loading on Rails app when Sidekiq < 6 [#377](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/377)
22
+ - [**BREAKING CHANGE**] Drop support for Sidekiq 3 [f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1](https://github.com/sidekiq-scheduler/sidekiq-scheduler/commit/f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1)
9
23
 
10
24
  # 4.0.0.alpha1
11
25
 
12
- - [**FIX**] Fix deprecated uses of Redis#pipelined [#357](https://github.com/moove-it/sidekiq-scheduler/pull/357)
13
- - [**DOCS**] Add docs for running multi-sidekiq configurations [#362](https://github.com/moove-it/sidekiq-scheduler/pull/362)
14
- - [**FIX**] Prevent sidekiq_options from overriding ActiveJob queue settings [#367](https://github.com/moove-it/sidekiq-scheduler/pull/367)
15
- - [**ENHANCEMENT**] Highlight disabled jobs [#369](https://github.com/moove-it/sidekiq-scheduler/pull/369)
16
- - [**BREAKING CHANGE**] Require redis 4.2.0 [#370](https://github.com/moove-it/sidekiq-scheduler/pull/370)
17
- - [**FIX**] Fixes redis deprecation warning regarding `exists` [#370](https://github.com/moove-it/sidekiq-scheduler/pull/370)
18
- - [**BREAKING CHANGE**] Remove dependecy on thwait and e2mmap [#371](https://github.com/moove-it/sidekiq-scheduler/pull/371)
19
- - Support Ruby 3.1 [#373](https://github.com/moove-it/sidekiq-scheduler/pull/373)
20
- - [**BREAKING CHANGE**] Set rufus_scheduler_options via sidekiq.yml file as configuration option [#375](https://github.com/moove-it/sidekiq-scheduler/pull/375)
26
+ - [**FIX**] Fix deprecated uses of Redis#pipelined [#357](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/357)
27
+ - [**DOCS**] Add docs for running multi-sidekiq configurations [#362](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/362)
28
+ - [**FIX**] Prevent sidekiq_options from overriding ActiveJob queue settings [#367](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/367)
29
+ - [**ENHANCEMENT**] Highlight disabled jobs [#369](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/369)
30
+ - [**BREAKING CHANGE**] Require redis 4.2.0 [#370](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/370)
31
+ - [**FIX**] Fixes redis deprecation warning regarding `exists` [#370](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/370)
32
+ - [**BREAKING CHANGE**] Remove dependecy on thwait and e2mmap [#371](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/371)
33
+ - Support Ruby 3.1 [#373](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/373)
34
+ - [**BREAKING CHANGE**] Set rufus_scheduler_options via sidekiq.yml file as configuration option [#375](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/375)
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # sidekiq-scheduler
2
2
 
3
3
  <p align="center">
4
- <a href="http://moove-it.github.io/sidekiq-scheduler/">
5
- <img src="https://moove-it.github.io/sidekiq-scheduler/images/small-logo.svg" width="468px" height="200px" alt="Sidekiq Scheduler" />
4
+ <a href="http://sidekiq-scheduler.github.io/sidekiq-scheduler/">
5
+ <img src="https://sidekiq-scheduler.github.io/sidekiq-scheduler/images/small-logo.svg" width="468px" height="200px" alt="Sidekiq Scheduler" />
6
6
  </a>
7
7
  </p>
8
8
 
@@ -10,19 +10,7 @@
10
10
  <a href="https://badge.fury.io/rb/sidekiq-scheduler">
11
11
  <img src="https://badge.fury.io/rb/sidekiq-scheduler.svg" alt="Gem Version">
12
12
  </a>
13
- <a href="https://codeclimate.com/github/moove-it/sidekiq-scheduler">
14
- <img src="https://codeclimate.com/github/moove-it/sidekiq-scheduler/badges/gpa.svg" alt="Code Climate">
15
- </a>
16
- <a href="https://travis-ci.org/moove-it/sidekiq-scheduler">
17
- <img src="https://api.travis-ci.org/moove-it/sidekiq-scheduler.svg?branch=master" alt="Build Status">
18
- </a>
19
- <a href="https://coveralls.io/github/moove-it/sidekiq-scheduler?branch=master">
20
- <img src="https://coveralls.io/repos/moove-it/sidekiq-scheduler/badge.svg?branch=master&service=github" alt="Coverage Status">
21
- </a>
22
- <a href="https://inch-ci.org/github/moove-it/sidekiq-scheduler">
23
- <img src="https://inch-ci.org/github/moove-it/sidekiq-scheduler.svg?branch=master" alt="Documentation Coverage">
24
- </a>
25
- <a href="http://www.rubydoc.info/github/moove-it/sidekiq-scheduler">
13
+ <a href="http://www.rubydoc.info/github/sidekiq-scheduler/sidekiq-scheduler">
26
14
  <img src="https://img.shields.io/badge/yard-docs-blue.svg" alt="Documentation">
27
15
  </a>
28
16
  </p>
@@ -30,7 +18,7 @@
30
18
  `sidekiq-scheduler` is an extension to [Sidekiq](http://github.com/mperham/sidekiq) that
31
19
  pushes jobs in a scheduled way, mimicking cron utility.
32
20
 
33
- __Note:__ Current branch contains work of the V4 release, if you are looking for version 2.2.* or 3.*, go to [2.2-stable branch](https://github.com/moove-it/sidekiq-scheduler/tree/2.2-stable) / [v3-stable](https://github.com/moove-it/sidekiq-scheduler/tree/v3-stable).
21
+ __Note:__ Current branch contains work of the v4 release, if you are looking for version 2.2.* or 3.*, 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).
34
22
 
35
23
  ## Installation
36
24
 
@@ -328,6 +316,47 @@ Non-normal conditions that could push a specific job multiple times are:
328
316
 
329
317
  `every`, `interval` and `in` jobs will be pushed once per host.
330
318
 
319
+ ### Suggested setup for Multiple Hosts using Heroku and Rails
320
+
321
+ Configuration options `every`, `interval` and `in` will push once per host. This may be undesirable. One way to achieve single jobs per the schedule would be to manually designate a host as the scheduler. The goal is to have a single scheduler process running across all your hosts.
322
+
323
+ This can be achieved by using an environment variable and controlling the number of dynos. In Rails, you can read this variable during initialization and then conditionally load your config file.
324
+
325
+ Suppose we are using Rails and have the following schedule:
326
+
327
+ ```yaml
328
+ # config/scheduler.yml
329
+ MyRegularJob:
330
+ description: "We want this job to run very often, but we do not want to run more of them as we scale"
331
+ interval: ["1m"]
332
+ queue: default
333
+ ```
334
+
335
+ Then we can conditionally load it via an initializer:
336
+
337
+ ```ruby
338
+ # config/initializer/sidekiq.rb
339
+ if ENV.fetch("IS_SCHEDULER", false)
340
+ Sidekiq.configure_server do |config|
341
+ config.on(:startup) do
342
+ Sidekiq.schedule = YAML.load_file(File.expand_path("../scheduler.yml", File.dirname(__FILE__)))
343
+ Sidekiq::Scheduler.reload_schedule!
344
+ end
345
+ end
346
+ end
347
+ ```
348
+
349
+ Then you would just need to flag the scheduler process when you start it. If you are using a Procfile, it would look like this:
350
+
351
+ ```yaml
352
+ # Procfile
353
+ web: bin/rails server
354
+ worker: bundle exec sidekiq -q default
355
+ scheduler: IS_SCHEDULER=true bundle exec sidekiq -q default
356
+ ```
357
+
358
+ When running via Heroku, you set your `scheduler` process to have 1 dyno. This will ensure you have at most 1 worker loading the schedule.
359
+
331
360
  ## Notes on when Sidekiq worker is down
332
361
 
333
362
  For a `cron`/`at` (and all other) job to be successfully enqueued, you need at least one sidekiq worker with scheduler to be up at that moment. Handling this is up to you and depends on your application.
@@ -387,7 +416,23 @@ Scheduler** for the other processes not responsible for the schedule. If you
387
416
  don't, the last booted Sidekiq processes' schedule will be what is stored in
388
417
  Redis.
389
418
 
390
- See https://github.com/moove-it/sidekiq-scheduler/issues/361 for a more details.
419
+ See https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/361 for a more details.
420
+
421
+ ## Notes when running multiple applications in the same Redis database
422
+
423
+ _NOTE_: **Although we support this option, we recommend having separate redis databases for each application. Choosing this option is at your own risk.**
424
+
425
+ If you need to run multiple applications with differing schedules, the easiest way is to use a different Redis database per application. Doing that will ensure that each application will have its own schedule, web interface and statistics.
426
+
427
+ However, you may want to have a set of related applications share the same Redis database in order to aggregate statistics and manage them all in a single web interface. To do this while maintaining a different schedule for each application, you can configure each application to use a different `key_prefix` in Redis. This prevents the applications overwriting each others' schedules and schedule data.
428
+
429
+ ```ruby
430
+ Rails.application.reloader.to_prepare do
431
+ SidekiqScheduler::RedisManager.key_prefix = "my-app"
432
+ end
433
+ ```
434
+
435
+ Note that this must be set before the schedule is loaded (or it will go into the wrong key). If you are using the web integration, make sure that the prefix is set in the web process so that you see the correct schedule.
391
436
 
392
437
  ## Sidekiq Web Integration
393
438
 
@@ -402,7 +447,7 @@ require 'sidekiq-scheduler/web'
402
447
  run Sidekiq::Web
403
448
  ```
404
449
 
405
- ![Sidekiq Web Integration](https://github.com/moove-it/sidekiq-scheduler/raw/master/images/recurring-jobs-ui-tab.png)
450
+ ![Sidekiq Web Integration](https://github.com/sidekiq-scheduler/sidekiq-scheduler/raw/master/images/recurring-jobs-ui-tab.png)
406
451
 
407
452
  ## ActiveJob integration
408
453
 
@@ -426,7 +471,7 @@ To see your updated schedule, be sure to reload Spring by stopping it prior to b
426
471
 
427
472
  Run `spring stop` to stop Spring.
428
473
 
429
- For more information, see [this issue](https://github.com/Moove-it/sidekiq-scheduler/issues/35#issuecomment-48067183) and [Spring's README](https://github.com/rails/spring/blob/master/README.md).
474
+ For more information, see [this issue](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/35#issuecomment-48067183) and [Spring's README](https://github.com/rails/spring/blob/master/README.md).
430
475
 
431
476
 
432
477
  ## Manage tasks from Unicorn/Rails server
@@ -7,7 +7,7 @@ Sidekiq::Web.tabs['recurring_jobs'] = 'recurring-jobs'
7
7
  Sidekiq::Web.locales << File.expand_path("#{File.dirname(__FILE__)}/../../../web/locales")
8
8
 
9
9
  if Sidekiq::VERSION >= '6.0.0'
10
- Sidekiq::Web.use Rack::Static, urls: ['/stylesheets'],
10
+ Sidekiq::Web.use Rack::Static, urls: ['/stylesheets-scheduler'],
11
11
  root: ASSETS_PATH,
12
12
  cascade: true,
13
13
  header_rules: [[:all, { 'Cache-Control' => 'public, max-age=86400' }]]
@@ -9,7 +9,7 @@ module SidekiqScheduler
9
9
  #
10
10
  # @return [String] schedule in JSON format
11
11
  def self.get_job_schedule(name)
12
- hget('schedules', name)
12
+ hget(schedules_key, name)
13
13
  end
14
14
 
15
15
  # Returns the state of a given job
@@ -44,7 +44,7 @@ module SidekiqScheduler
44
44
  # @param [String] name The name of the job
45
45
  # @param [Hash] config The new schedule for the job
46
46
  def self.set_job_schedule(name, config)
47
- hset('schedules', name, JSON.generate(config))
47
+ hset(schedules_key, name, JSON.generate(config))
48
48
  end
49
49
 
50
50
  # Sets the state for a given job
@@ -60,7 +60,7 @@ module SidekiqScheduler
60
60
  # @param [String] name The name of the job
61
61
  # @param [String] next_time The next time the job has to be executed
62
62
  def self.set_job_next_time(name, next_time)
63
- hset(next_times_key, name, next_time)
63
+ hset(next_times_key, name, String(next_time))
64
64
  end
65
65
 
66
66
  # Sets the last execution time for a given job
@@ -68,14 +68,14 @@ module SidekiqScheduler
68
68
  # @param [String] name The name of the job
69
69
  # @param [String] last_time The last time the job was executed
70
70
  def self.set_job_last_time(name, last_time)
71
- hset(last_times_key, name, last_time)
71
+ hset(last_times_key, name, String(last_time))
72
72
  end
73
73
 
74
74
  # Removes the schedule for a given job
75
75
  #
76
76
  # @param [String] name The name of the job
77
77
  def self.remove_job_schedule(name)
78
- hdel('schedules', name)
78
+ hdel(schedules_key, name)
79
79
  end
80
80
 
81
81
  # Removes the next execution time for a given job
@@ -89,14 +89,14 @@ module SidekiqScheduler
89
89
  #
90
90
  # @return [Hash] hash with all the job schedules
91
91
  def self.get_all_schedules
92
- Sidekiq.redis { |r| r.hgetall('schedules') }
92
+ Sidekiq.redis { |r| r.hgetall(schedules_key) }
93
93
  end
94
94
 
95
95
  # Returns boolean value that indicates if the schedules value exists
96
96
  #
97
97
  # @return [Boolean] true if the schedules key is set, false otherwise
98
98
  def self.schedule_exist?
99
- Sidekiq.redis { |r| r.exists?('schedules') }
99
+ Sidekiq.redis { |r| r.exists?(schedules_key) }
100
100
  end
101
101
 
102
102
  # Returns all the schedule changes for a given time range.
@@ -106,19 +106,19 @@ module SidekiqScheduler
106
106
  #
107
107
  # @return [Array] array with all the changed job names
108
108
  def self.get_schedule_changes(from, to)
109
- Sidekiq.redis { |r| r.zrangebyscore('schedules_changed', from, "(#{to}") }
109
+ Sidekiq.redis { |r| r.zrangebyscore(schedules_changed_key, from, "(#{to}") }
110
110
  end
111
111
 
112
112
  # Register a schedule change for a given job
113
113
  #
114
114
  # @param [String] name The name of the job
115
115
  def self.add_schedule_change(name)
116
- Sidekiq.redis { |r| r.zadd('schedules_changed', Time.now.to_f, name) }
116
+ Sidekiq.redis { |r| r.zadd(schedules_changed_key, Time.now.to_f, name) }
117
117
  end
118
118
 
119
119
  # Remove all the schedule changes records
120
120
  def self.clean_schedules_changed
121
- Sidekiq.redis { |r| r.del('schedules_changed') unless r.type('schedules_changed') == 'zset' }
121
+ Sidekiq.redis { |r| r.del(schedules_changed_key) unless r.type(schedules_changed_key) == 'zset' }
122
122
  end
123
123
 
124
124
  # Removes a queued job instance
@@ -156,28 +156,57 @@ module SidekiqScheduler
156
156
  #
157
157
  # @return [String] the pushed job key
158
158
  def self.pushed_job_key(job_name)
159
- "sidekiq-scheduler:pushed:#{job_name}"
159
+ "#{key_prefix}sidekiq-scheduler:pushed:#{job_name}"
160
160
  end
161
161
 
162
162
  # Returns the key of the Redis hash for job's execution times hash
163
163
  #
164
164
  # @return [String] with the key
165
165
  def self.next_times_key
166
- 'sidekiq-scheduler:next_times'
166
+ "#{key_prefix}sidekiq-scheduler:next_times"
167
167
  end
168
168
 
169
169
  # Returns the key of the Redis hash for job's last execution times hash
170
170
  #
171
171
  # @return [String] with the key
172
172
  def self.last_times_key
173
- 'sidekiq-scheduler:last_times'
173
+ "#{key_prefix}sidekiq-scheduler:last_times"
174
174
  end
175
175
 
176
176
  # Returns the Redis's key for saving schedule states.
177
177
  #
178
178
  # @return [String] with the key
179
179
  def self.schedules_state_key
180
- 'sidekiq-scheduler:states'
180
+ "#{key_prefix}sidekiq-scheduler:states"
181
+ end
182
+
183
+ # Returns the Redis's key for saving schedules.
184
+ #
185
+ # @return [String] with the key
186
+ def self.schedules_key
187
+ "#{key_prefix}schedules"
188
+ end
189
+
190
+ # Returns the Redis's key for saving schedule changes.
191
+ #
192
+ # @return [String] with the key
193
+ def self.schedules_changed_key
194
+ "#{key_prefix}schedules_changed"
195
+ end
196
+
197
+ # Returns the key prefix used to generate all scheduler keys
198
+ #
199
+ # @return [String] with the key prefix
200
+ def self.key_prefix
201
+ @key_prefix
202
+ end
203
+
204
+ # Sets the key prefix used to scope all scheduler keys
205
+ #
206
+ # @param [String] value The string to use as the prefix. A ":" will be appended as a delimiter if needed.
207
+ def self.key_prefix=(value)
208
+ value = "#{value}:" if value && !%w[. :].include?(value[-1])
209
+ @key_prefix = value
181
210
  end
182
211
 
183
212
  private
@@ -148,9 +148,7 @@ module SidekiqScheduler
148
148
  end
149
149
 
150
150
  def try_to_constantize(klass)
151
- klass.is_a?(String) ? klass.constantize : klass
152
- rescue NameError
153
- klass
151
+ SidekiqScheduler::Utils.try_to_constantize(klass)
154
152
  end
155
153
  end
156
154
  end
@@ -57,7 +57,7 @@ module SidekiqScheduler
57
57
  def print_schedule
58
58
  if rufus_scheduler
59
59
  Sidekiq.logger.info "Scheduling Info\tLast Run"
60
- scheduler_jobs = rufus_scheduler.all_jobs
60
+ scheduler_jobs = rufus_scheduler.jobs
61
61
  scheduler_jobs.each_value do |v|
62
62
  Sidekiq.logger.info "#{v.t}\t#{v.last}\t"
63
63
  end
@@ -158,7 +158,7 @@ module SidekiqScheduler
158
158
  config = prepare_arguments(job_config.dup)
159
159
 
160
160
  if config.delete('include_metadata')
161
- config['args'] = arguments_with_metadata(config['args'], scheduled_at: time.to_f)
161
+ config['args'] = arguments_with_metadata(config['args'], "scheduled_at" => time.to_f)
162
162
  end
163
163
 
164
164
  if SidekiqScheduler::Utils.active_job_enqueue?(config['class'])
@@ -228,6 +228,14 @@ module SidekiqScheduler
228
228
  set_schedule_state(name, state)
229
229
  end
230
230
 
231
+ def toggle_all_jobs(new_state)
232
+ Sidekiq.schedule!.keys.each do |name|
233
+ state = schedule_state(name)
234
+ state['enabled'] = new_state
235
+ set_schedule_state(name, state)
236
+ end
237
+ end
238
+
231
239
  private
232
240
 
233
241
  def new_job(name, interval_type, config, schedule, options)
@@ -284,7 +292,11 @@ module SidekiqScheduler
284
292
  end
285
293
 
286
294
  def sidekiq_queues
287
- Sidekiq.options[:queues].map(&:to_s)
295
+ if SIDEKIQ_GTE_6_5_0
296
+ Sidekiq[:queues].map(&:to_s)
297
+ else
298
+ Sidekiq.options[:queues].map(&:to_s)
299
+ end
288
300
  end
289
301
 
290
302
  # Returns true if a job's queue is included in the array of queues
@@ -49,7 +49,7 @@ module SidekiqScheduler
49
49
  #
50
50
  # @return [Class] the class corresponding to the klass param
51
51
  def self.try_to_constantize(klass)
52
- klass.is_a?(String) ? klass.constantize : klass
52
+ klass.is_a?(String) ? Object.const_get(klass) : klass
53
53
  rescue NameError
54
54
  klass
55
55
  end
@@ -112,8 +112,10 @@ module SidekiqScheduler
112
112
  def self.new_rufus_scheduler(options = {})
113
113
  Rufus::Scheduler.new(options).tap do |scheduler|
114
114
  scheduler.define_singleton_method(:on_post_trigger) do |job, triggered_time|
115
- SidekiqScheduler::Utils.update_job_last_time(job.tags[0], triggered_time)
116
- SidekiqScheduler::Utils.update_job_next_time(job.tags[0], job.next_time)
115
+ if (job_name = job.tags[0])
116
+ SidekiqScheduler::Utils.update_job_last_time(job_name, triggered_time)
117
+ SidekiqScheduler::Utils.update_job_next_time(job_name, job.next_time)
118
+ end
117
119
  end
118
120
  end
119
121
  end
@@ -1,3 +1,3 @@
1
1
  module SidekiqScheduler
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.3"
3
3
  end
@@ -27,6 +27,11 @@ module SidekiqScheduler
27
27
  SidekiqScheduler::Scheduler.instance.toggle_job_enabled(params[:name])
28
28
  redirect "#{root_path}recurring-jobs"
29
29
  end
30
+
31
+ app.post '/recurring-jobs/toggle-all' do
32
+ SidekiqScheduler::Scheduler.instance.toggle_all_jobs(params[:action] == 'enable')
33
+ redirect "#{root_path}recurring-jobs"
34
+ end
30
35
  end
31
36
  end
32
37
  end
@@ -7,19 +7,33 @@ require_relative 'sidekiq-scheduler/manager'
7
7
  require_relative 'sidekiq-scheduler/redis_manager'
8
8
  require_relative 'sidekiq-scheduler/extensions/schedule'
9
9
 
10
+ SIDEKIQ_GTE_6_5_0 = Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
11
+
10
12
  Sidekiq.configure_server do |config|
11
13
 
12
14
  config.on(:startup) do
13
15
  # schedules_changed's type was changed from SET to ZSET, so we remove old versions at startup
14
16
  SidekiqScheduler::RedisManager.clean_schedules_changed
15
17
 
16
- schedule_manager = SidekiqScheduler::Manager.new(config.options)
17
- config.options[:schedule_manager] = schedule_manager
18
- config.options[:schedule_manager].start
18
+ # Accessing the raw @config hash through .options is deprecated in 6.5 and to be removed in 7.0
19
+ config_options = SIDEKIQ_GTE_6_5_0 ? Sidekiq.instance_variable_get(:@config) : config.options
20
+
21
+ schedule_manager = SidekiqScheduler::Manager.new(config_options)
22
+ if SIDEKIQ_GTE_6_5_0
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
19
29
  end
20
30
 
21
31
  config.on(:quiet) do
22
- config.options[:schedule_manager].stop
32
+ if SIDEKIQ_GTE_6_5_0
33
+ config[:schedule_manager].stop
34
+ else
35
+ config.options[:schedule_manager].stop
36
+ end
23
37
  end
24
38
 
25
39
  end
@@ -25,3 +25,18 @@
25
25
  border: 1px solid #555;
26
26
  }
27
27
  }
28
+
29
+ .toggle-all-buttons {
30
+ margin-top: 20px;
31
+ margin-bottom: 10px;
32
+ line-height: 45px;
33
+ text-align: right;
34
+ }
35
+
36
+ @media (max-width: 768px) {
37
+ .toggle-all-buttons {
38
+ margin-top: 0;
39
+ text-align: left;
40
+ line-height: inherit;
41
+ }
42
+ }
data/web/locales/de.yml CHANGED
@@ -12,3 +12,5 @@ de:
12
12
  no_next_time: Keine zukünftige Ausführung für diesen Job
13
13
  disable: Deaktivieren
14
14
  enable: Aktivieren
15
+ disable_all: Alle deaktivieren
16
+ enable_all: Alle aktivieren
data/web/locales/en.yml CHANGED
@@ -12,3 +12,5 @@ en:
12
12
  no_next_time: no next execution for this job
13
13
  disable: Disable
14
14
  enable: Enable
15
+ disable_all: Disable all
16
+ enable_all: Enable all
data/web/locales/ru.yml CHANGED
@@ -12,3 +12,5 @@ ru:
12
12
  no_next_time: выполнение задачи не запланировано
13
13
  disable: Выключить
14
14
  enable: Включить
15
+ disable_all: Выключить все
16
+ enable_all: Включить все
@@ -1,5 +1,5 @@
1
1
  <% if Sidekiq::VERSION >= '6.0.0' %>
2
- <link href="<%= root_path %>stylesheets/recurring_jobs.css" media="screen" rel="stylesheet" type="text/css" />
2
+ <link href="<%= root_path %>stylesheets-scheduler/recurring_jobs.css" media="screen" rel="stylesheet" type="text/css" />
3
3
  <% else %>
4
4
  <style>
5
5
  .recurring-jobs { border-top-left-radius: 4px; border-top-right-radius: 4px; }
@@ -21,10 +21,36 @@
21
21
  .list-group-item-disabled {
22
22
  background-color: #f3d3d3;
23
23
  }
24
+
25
+ .toggle-all-buttons {
26
+ margin-top: 20px;
27
+ margin-bottom: 10px;
28
+ line-height: 45px;
29
+ text-align: right;
30
+ }
31
+
32
+ @media (max-width: 768px) {
33
+ .toggle-all-buttons {
34
+ margin-top: 0;
35
+ text-align: left;
36
+ line-height: inherit;
37
+ }
38
+ }
24
39
  </style>
25
40
  <% end %>
26
41
 
27
- <h3><%= t('recurring_jobs') %></h3>
42
+ <div class="row">
43
+ <div class="col-sm-6">
44
+ <h3><%= t('recurring_jobs') %></h3>
45
+ </div>
46
+ <div class="col-sm-6 toggle-all-buttons">
47
+ <form action="<%= root_path %>recurring-jobs/toggle-all" method="post">
48
+ <%= csrf_tag %>
49
+ <button type="submit" class="btn btn-warn btn-xs" name="action" value="enable"><%= t('enable_all') %></button>
50
+ <button type="submit" class="btn btn-warn btn-xs" name="action" value="disable"><%= t('disable_all') %></button>
51
+ </form>
52
+ </div>
53
+ </div>
28
54
 
29
55
  <div class="recurring-jobs">
30
56
  <ul class="list-group">
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.0.1
4
+ version: 4.0.3
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-06-08 00:00:00.000000000 Z
13
+ date: 2022-10-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sidekiq
@@ -19,6 +19,9 @@ dependencies:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '4'
22
+ - - "<"
23
+ - !ruby/object:Gem::Version
24
+ version: '7'
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,6 +29,9 @@ dependencies:
26
29
  - - ">="
27
30
  - !ruby/object:Gem::Version
28
31
  version: '4'
32
+ - - "<"
33
+ - !ruby/object:Gem::Version
34
+ version: '7'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: redis
31
37
  requirement: !ruby/object:Gem::Requirement
@@ -124,20 +130,6 @@ dependencies:
124
130
  - - ">="
125
131
  - !ruby/object:Gem::Version
126
132
  version: '0'
127
- - !ruby/object:Gem::Dependency
128
- name: mock_redis
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - "~>"
132
- - !ruby/object:Gem::Version
133
- version: 0.28.0
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - "~>"
139
- - !ruby/object:Gem::Version
140
- version: 0.28.0
141
133
  - !ruby/object:Gem::Dependency
142
134
  name: simplecov
143
135
  requirement: !ruby/object:Gem::Requirement
@@ -234,7 +226,7 @@ files:
234
226
  - lib/sidekiq-scheduler/version.rb
235
227
  - lib/sidekiq-scheduler/web.rb
236
228
  - lib/sidekiq/scheduler.rb
237
- - web/assets/stylesheets/recurring_jobs.css
229
+ - web/assets/stylesheets-scheduler/recurring_jobs.css
238
230
  - web/locales/cs.yml
239
231
  - web/locales/de.yml
240
232
  - web/locales/en.yml
@@ -249,7 +241,7 @@ files:
249
241
  - web/locales/sv.yml
250
242
  - web/locales/zh-cn.yml
251
243
  - web/views/recurring_jobs.erb
252
- homepage: https://moove-it.github.io/sidekiq-scheduler/
244
+ homepage: https://sidekiq-scheduler.github.io/sidekiq-scheduler/
253
245
  licenses:
254
246
  - MIT
255
247
  metadata: {}
@@ -268,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
260
  - !ruby/object:Gem::Version
269
261
  version: '0'
270
262
  requirements: []
271
- rubygems_version: 3.2.19
263
+ rubygems_version: 3.1.6
272
264
  signing_key:
273
265
  specification_version: 4
274
266
  summary: Light weight job scheduling extension for Sidekiq