sidekiq-scheduler 3.2.2 → 4.0.0.alpha1

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: b7d47069eda4c979115cb594aa870a55546a7fe1b895053fb2df69b0962163eb
4
- data.tar.gz: e966ab0f5aa48ec3fef2adfe4327e8b72b38f1c4f8da593052e9227e3396b69c
3
+ metadata.gz: 2a45a1821398ad12b4ebc760efb1ac6aec3c62d38a1176f2a9c804a2dbf08fab
4
+ data.tar.gz: 5a9a8cb6e9c7a8262829c9f53a5aacb7ae91e5ae411627da1c189a471b803e12
5
5
  SHA512:
6
- metadata.gz: f45636415dac48c0882d75449475d10de07beb6d1f1bfe2873d71f0264f65f2cb58a7a5dd42ff5bd784d79f46f2bd4f00ceb2d27bae47fcc80796b5dbcd22be8
7
- data.tar.gz: e338d8ff6767dbe7ea21a22fd23d702d49b7095a64be296843d97dcaa415b9c73867edd0601dd4839ccce91bdf271aabaa458d9954b6cb2e42273dd460428383
6
+ metadata.gz: 9772349882c5194d63775696468722b637dd1ec6c420027ef25107a0821c073e6440fa797d41432e4b93c1da9964f03a3032eb3853b57fa23525a08ba606b68d
7
+ data.tar.gz: 4d424d7826176deb095cfa9450392eb3aa0b8630ee446a7dc0daf917e4ddd6c77c2bc8f7259bcb2450554bbdc77ecf3772dfbdd4f757eff1be7c7661c9bab392
data/README.md CHANGED
@@ -30,7 +30,7 @@
30
30
  `sidekiq-scheduler` is an extension to [Sidekiq](http://github.com/mperham/sidekiq) that
31
31
  pushes jobs in a scheduled way, mimicking cron utility.
32
32
 
33
- __Note:__ If you are looking for version 2.2.*, go to [2.2-stable branch](https://github.com/moove-it/sidekiq-scheduler/tree/2.2-stable).
33
+ __Note:__ Current branch contains work for a 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).
34
34
 
35
35
  ## Installation
36
36
 
@@ -100,6 +100,7 @@ Available options are:
100
100
  :enabled: <enables scheduler if true [true by default]>
101
101
  :scheduler:
102
102
  :listened_queues_only: <push jobs whose queue is being listened by sidekiq [false by default]>
103
+ :rufus_scheduler_options: <Set custom options for rufus scheduler, like max_work_threads [{} by default]>
103
104
  ```
104
105
 
105
106
  ## Schedule configuration
@@ -304,10 +305,16 @@ If you're configuring your own Redis connection pool, you need to make sure the
304
305
 
305
306
  That's a minimum of `concurrency` + 5 (per the [Sidekiq wiki](https://github.com/mperham/sidekiq/wiki/Using-Redis#complete-control)) + `Rufus::Scheduler::MAX_WORK_THREADS` (28 as of this writing; per the [Rufus README](https://github.com/jmettraux/rufus-scheduler#max_work_threads)), for a total of 58 with the default `concurrency` of 25.
306
307
 
307
- You can also override the thread pool size in Rufus Scheduler by setting e.g.:
308
+ You can also override the thread pool size in Rufus Scheduler by setting the following in your `sidekiq.yml` config:
308
309
 
309
- ```
310
- SidekiqScheduler::Scheduler.instance.rufus_scheduler_options = { max_work_threads: 5 }
310
+ ```yaml
311
+ ---
312
+ ...
313
+
314
+ rufus_scheduler_options:
315
+ max_work_threads: 5
316
+
317
+ ...
311
318
  ```
312
319
 
313
320
  ## Notes about running on Multiple Hosts
@@ -321,7 +328,7 @@ Non-normal conditions that could push a specific job multiple times are:
321
328
 
322
329
  `every`, `interval` and `in` jobs will be pushed once per host.
323
330
 
324
- ## Notes on when sidekiq worker is down
331
+ ## Notes on when Sidekiq worker is down
325
332
 
326
333
  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.
327
334
 
@@ -334,6 +341,54 @@ Possible solutions include:
334
341
 
335
342
  Each option has it's own pros and cons.
336
343
 
344
+ ## Notes when running multiple Sidekiq processors on the same Redis
345
+
346
+ ### TL;DR
347
+
348
+ Be **sure** to include the `:enabled: false` top-level key on any additional
349
+ configurations to avoid any possibility of the `schedules` definition being
350
+ wiped by the second Sidekiq process.
351
+
352
+ To illustrate what we mean:
353
+
354
+ Say you have one process with the schedule:
355
+ ```yaml
356
+ # e.g., config/sidekiq.yml
357
+
358
+ :queues:
359
+ - default
360
+ :schedule:
361
+ do_something_every_minute:
362
+ class: DoSomethingJob
363
+ args: matey
364
+ queue: :scheduler
365
+ cron: '0 * * * * * America/Los_Angeles'
366
+ ```
367
+
368
+ And a separate separate configured process without one:
369
+ ```yaml
370
+ # e.g., config/sidekiq_other.yml
371
+ :queues:
372
+ - scheduler
373
+
374
+ ## NOTE Disable the Scheduler
375
+ :enabled: false
376
+ ```
377
+
378
+ ### Details
379
+
380
+ This gem stores the configured schedule in Redis on boot. It's used, primarily,
381
+ to display in the Web Integration, and allow you to interact with that schedule
382
+ via that integration.
383
+
384
+ If you're running multiple Sidekiq processes on the same Redis namespace with
385
+ different configurations, **you'll want to explicitly _disable_ Sidekiq
386
+ Scheduler** for the other processes not responsible for the schedule. If you
387
+ don't, the last booted Sidekiq processes' schedule will be what is stored in
388
+ Redis.
389
+
390
+ See https://github.com/moove-it/sidekiq-scheduler/issues/361 for a more details.
391
+
337
392
  ## Sidekiq Web Integration
338
393
 
339
394
  sidekiq-scheduler provides an extension to the Sidekiq web interface that adds a `Recurring Jobs` page.
@@ -408,6 +463,7 @@ MIT License
408
463
 
409
464
  ## Copyright
410
465
 
411
- Copyright 2013 - 2018 Moove-IT.
412
- Copyright 2012 Morton Jonuschat.
413
- Some parts copyright 2010 Ben VandenBos.
466
+ - Copyright 2021 - 2022 Marcelo Lauxen.
467
+ - Copyright 2013 - 2022 Moove-IT.
468
+ - Copyright 2012 Morton Jonuschat.
469
+ - Some parts copyright 2010 Ben VandenBos.
@@ -5,10 +5,7 @@ ASSETS_PATH = File.expand_path('../../../web/assets', __dir__)
5
5
  Sidekiq::Web.register(SidekiqScheduler::Web)
6
6
  Sidekiq::Web.tabs['recurring_jobs'] = 'recurring-jobs'
7
7
  Sidekiq::Web.locales << File.expand_path("#{File.dirname(__FILE__)}/../../../web/locales")
8
-
9
- if Sidekiq::VERSION >= '6.0.0'
10
- Sidekiq::Web.use Rack::Static, urls: ['/stylesheets'],
11
- root: ASSETS_PATH,
12
- cascade: true,
13
- header_rules: [[:all, { 'Cache-Control' => 'public, max-age=86400' }]]
14
- end
8
+ Sidekiq::Web.use Rack::Static, urls: ['/stylesheets'],
9
+ root: ASSETS_PATH,
10
+ cascade: true,
11
+ header_rules: [[:all, { 'Cache-Control' => 'public, max-age=86400' }]]
@@ -1,5 +1,7 @@
1
1
  require 'redis'
2
2
 
3
+ require 'sidekiq/util'
4
+
3
5
  require 'sidekiq-scheduler/schedule'
4
6
  require 'sidekiq-scheduler/scheduler'
5
7
 
@@ -10,6 +12,8 @@ module SidekiqScheduler
10
12
  # from Redis onto the work queues
11
13
  #
12
14
  class Manager
15
+ include Sidekiq::Util
16
+
13
17
  DEFAULT_SCHEDULER_OPTIONS = {
14
18
  enabled: true,
15
19
  dynamic: false,
@@ -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', 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', name, JSON.generate(config))
48
48
  end
49
49
 
50
50
  # Sets the state for a given job
@@ -75,7 +75,7 @@ module SidekiqScheduler
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', name)
79
79
  end
80
80
 
81
81
  # Removes the next execution time for a given job
@@ -89,21 +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') }
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 do |r|
100
- case r.exists(:schedules)
101
- when true, 1
102
- true
103
- else
104
- false
105
- end
106
- end
99
+ Sidekiq.redis { |r| r.exists?('schedules') }
107
100
  end
108
101
 
109
102
  # Returns all the schedule changes for a given time range.
@@ -113,19 +106,19 @@ module SidekiqScheduler
113
106
  #
114
107
  # @return [Array] array with all the changed job names
115
108
  def self.get_schedule_changes(from, to)
116
- Sidekiq.redis { |r| r.zrangebyscore(:schedules_changed, from, "(#{to}") }
109
+ Sidekiq.redis { |r| r.zrangebyscore('schedules_changed', from, "(#{to}") }
117
110
  end
118
111
 
119
112
  # Register a schedule change for a given job
120
113
  #
121
114
  # @param [String] name The name of the job
122
115
  def self.add_schedule_change(name)
123
- Sidekiq.redis { |r| r.zadd(:schedules_changed, Time.now.to_f, name) }
116
+ Sidekiq.redis { |r| r.zadd('schedules_changed', Time.now.to_f, name) }
124
117
  end
125
118
 
126
119
  # Remove all the schedule changes records
127
120
  def self.clean_schedules_changed
128
- Sidekiq.redis { |r| r.del(:schedules_changed) unless r.type(:schedules_changed) == 'zset' }
121
+ Sidekiq.redis { |r| r.del('schedules_changed') unless r.type('schedules_changed') == 'zset' }
129
122
  end
130
123
 
131
124
  # Removes a queued job instance
@@ -188,7 +181,7 @@ module SidekiqScheduler
188
181
  end
189
182
 
190
183
  private
191
-
184
+
192
185
  # Returns the value of a Redis stored hash field
193
186
  #
194
187
  # @param [String] hash_key The key name of the hash
@@ -1,11 +1,13 @@
1
1
  require 'rufus/scheduler'
2
- require 'thwait'
2
+ require 'sidekiq/util'
3
3
  require 'json'
4
4
  require 'sidekiq-scheduler/rufus_utils'
5
5
  require 'sidekiq-scheduler/redis_manager'
6
6
 
7
7
  module SidekiqScheduler
8
8
  class Scheduler
9
+ extend Sidekiq::Util
10
+
9
11
  # We expect rufus jobs to have #params
10
12
  Rufus::Scheduler::Job.module_eval do
11
13
  alias_method :params, :opts
@@ -23,6 +25,9 @@ module SidekiqScheduler
23
25
  # Set to schedule jobs only when will be pushed to queues listened by sidekiq
24
26
  attr_accessor :listened_queues_only
25
27
 
28
+ # Set custom options for rufus scheduler, like max_work_threads.
29
+ attr_accessor :rufus_scheduler_options
30
+
26
31
  class << self
27
32
 
28
33
  def instance
@@ -44,6 +49,7 @@ module SidekiqScheduler
44
49
  self.dynamic = options[:dynamic]
45
50
  self.dynamic_every = options[:dynamic_every]
46
51
  self.listened_queues_only = options[:listened_queues_only]
52
+ self.rufus_scheduler_options = options[:rufus_scheduler_options] || {}
47
53
  end
48
54
 
49
55
  # the Rufus::Scheduler jobs that are scheduled
@@ -165,14 +171,6 @@ module SidekiqScheduler
165
171
  end
166
172
  end
167
173
 
168
- def rufus_scheduler_options
169
- @rufus_scheduler_options ||= {}
170
- end
171
-
172
- def rufus_scheduler_options=(options)
173
- @rufus_scheduler_options = options
174
- end
175
-
176
174
  def rufus_scheduler
177
175
  @rufus_scheduler ||= SidekiqScheduler::Utils.new_rufus_scheduler(rufus_scheduler_options)
178
176
  end
@@ -1,3 +1,3 @@
1
1
  module SidekiqScheduler
2
- VERSION = '3.2.2'
2
+ VERSION = "4.0.0.alpha1"
3
3
  end
@@ -1,28 +1,4 @@
1
- <% if Sidekiq::VERSION >= '6.0.0' %>
2
- <link href="<%= root_path %>stylesheets/recurring_jobs.css" media="screen" rel="stylesheet" type="text/css" />
3
- <% else %>
4
- <style>
5
- .recurring-jobs { border-top-left-radius: 4px; border-top-right-radius: 4px; }
6
- .recurring-jobs .title { margin-bottom: 5px; }
7
- .recurring-jobs .title .name { font-weight: bold;}
8
- .recurring-jobs .info,
9
- .recurring-jobs .description { margin-bottom: 5px; }
10
- .recurring-jobs .actions { margin-bottom: 5px; }
11
- .recurring-jobs .status,
12
- .recurring-jobs .description { font-size: 12px; }
13
- .recurring-jobs .enqueue { margin-bottom: 0.5rem }
14
-
15
- .list-group-item {
16
- background-color: #f3f3f3;
17
- color: #585454;
18
- border: 1px solid rgba(0, 0, 0, 0.1);
19
- }
20
-
21
- .list-group-item-disabled {
22
- background-color: #f3d3d3;
23
- }
24
- </style>
25
- <% end %>
1
+ <link href="<%= root_path %>stylesheets/recurring_jobs.css" media="screen" rel="stylesheet" type="text/css" />
26
2
 
27
3
  <h3><%= t('recurring_jobs') %></h3>
28
4
 
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 4.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morton Jonuschat
8
8
  - Moove-it
9
+ - Marcelo Lauxen
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2022-06-08 00:00:00.000000000 Z
13
+ date: 2022-04-21 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: sidekiq
@@ -31,20 +32,14 @@ dependencies:
31
32
  requirements:
32
33
  - - ">="
33
34
  - !ruby/object:Gem::Version
34
- version: '3'
35
- - - "<"
36
- - !ruby/object:Gem::Version
37
- version: '5'
35
+ version: 4.2.0
38
36
  type: :runtime
39
37
  prerelease: false
40
38
  version_requirements: !ruby/object:Gem::Requirement
41
39
  requirements:
42
40
  - - ">="
43
41
  - !ruby/object:Gem::Version
44
- version: '3'
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '5'
42
+ version: 4.2.0
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: rufus-scheduler
50
45
  requirement: !ruby/object:Gem::Requirement
@@ -73,34 +68,6 @@ dependencies:
73
68
  - - ">="
74
69
  - !ruby/object:Gem::Version
75
70
  version: 1.4.0
76
- - !ruby/object:Gem::Dependency
77
- name: thwait
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- - !ruby/object:Gem::Dependency
91
- name: e2mmap
92
- requirement: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- type: :runtime
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
71
  - !ruby/object:Gem::Dependency
105
72
  name: rake
106
73
  requirement: !ruby/object:Gem::Requirement
@@ -119,28 +86,28 @@ dependencies:
119
86
  name: timecop
120
87
  requirement: !ruby/object:Gem::Requirement
121
88
  requirements:
122
- - - "~>"
89
+ - - ">="
123
90
  - !ruby/object:Gem::Version
124
91
  version: '0'
125
92
  type: :development
126
93
  prerelease: false
127
94
  version_requirements: !ruby/object:Gem::Requirement
128
95
  requirements:
129
- - - "~>"
96
+ - - ">="
130
97
  - !ruby/object:Gem::Version
131
98
  version: '0'
132
99
  - !ruby/object:Gem::Dependency
133
100
  name: mocha
134
101
  requirement: !ruby/object:Gem::Requirement
135
102
  requirements:
136
- - - "~>"
103
+ - - ">="
137
104
  - !ruby/object:Gem::Version
138
105
  version: '0'
139
106
  type: :development
140
107
  prerelease: false
141
108
  version_requirements: !ruby/object:Gem::Requirement
142
109
  requirements:
143
- - - "~>"
110
+ - - ">="
144
111
  - !ruby/object:Gem::Version
145
112
  version: '0'
146
113
  - !ruby/object:Gem::Dependency
@@ -163,30 +130,16 @@ dependencies:
163
130
  requirements:
164
131
  - - "~>"
165
132
  - !ruby/object:Gem::Version
166
- version: 0.19.0
133
+ version: 0.28.0
167
134
  type: :development
168
135
  prerelease: false
169
136
  version_requirements: !ruby/object:Gem::Requirement
170
137
  requirements:
171
138
  - - "~>"
172
139
  - !ruby/object:Gem::Version
173
- version: 0.19.0
140
+ version: 0.28.0
174
141
  - !ruby/object:Gem::Dependency
175
142
  name: simplecov
176
- requirement: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- type: :development
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- - !ruby/object:Gem::Dependency
189
- name: byebug
190
143
  requirement: !ruby/object:Gem::Requirement
191
144
  requirements:
192
145
  - - ">="
@@ -200,7 +153,7 @@ dependencies:
200
153
  - !ruby/object:Gem::Version
201
154
  version: '0'
202
155
  - !ruby/object:Gem::Dependency
203
- name: activejob
156
+ name: byebug
204
157
  requirement: !ruby/object:Gem::Requirement
205
158
  requirements:
206
159
  - - ">="
@@ -214,7 +167,7 @@ dependencies:
214
167
  - !ruby/object:Gem::Version
215
168
  version: '0'
216
169
  - !ruby/object:Gem::Dependency
217
- name: coveralls
170
+ name: activejob
218
171
  requirement: !ruby/object:Gem::Requirement
219
172
  requirements:
220
173
  - - ">="
@@ -259,11 +212,11 @@ description: Light weight job scheduling extension for Sidekiq that adds support
259
212
  queueing jobs in a recurring way.
260
213
  email:
261
214
  - sidekiq-scheduler@moove-it.com
215
+ - marcelolauxen16@gmail.com
262
216
  executables: []
263
217
  extensions: []
264
218
  extra_rdoc_files: []
265
219
  files:
266
- - CHANGELOG.md
267
220
  - MIT-LICENSE
268
221
  - README.md
269
222
  - Rakefile
@@ -307,12 +260,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
260
  requirements:
308
261
  - - ">="
309
262
  - !ruby/object:Gem::Version
310
- version: '0'
263
+ version: '2.5'
311
264
  required_rubygems_version: !ruby/object:Gem::Requirement
312
265
  requirements:
313
- - - ">="
266
+ - - ">"
314
267
  - !ruby/object:Gem::Version
315
- version: '0'
268
+ version: 1.3.1
316
269
  requirements: []
317
270
  rubygems_version: 3.2.19
318
271
  signing_key:
data/CHANGELOG.md DELETED
@@ -1,11 +0,0 @@
1
- # 3.2.2
2
-
3
- - [FIX] Add support for sidekiq 6.5 #382
4
-
5
- # 3.2.1
6
- - Fix CSS not loading on Rails app when Sidekiq < 6 https://github.com/moove-it/sidekiq-scheduler/pull/377
7
- # 3.2.0
8
-
9
- - Fix deprecated uses of Redis#pipelined https://github.com/moove-it/sidekiq-scheduler/pull/357
10
- - Prevent sidekiq_options from overriding ActiveJob queue settings https://github.com/moove-it/sidekiq-scheduler/pull/367
11
- - Highlight disabled jobs https://github.com/moove-it/sidekiq-scheduler/pull/369