sidekiq-cron 1.7.0 → 1.8.0

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: d16f511a8148eadb1246263f53b596b643f9a653e0fb7877e8eaa6e0d0f2f57c
4
- data.tar.gz: 874babda0f4da8f7928b69a226b967d79d59eacc79c101d0e087f064d31e6423
3
+ metadata.gz: 7df934577b0740b3e977ffd0e361f6333de6958921659d78bf4c4e4a0015aad9
4
+ data.tar.gz: 6ae3317c56ff984bf0b651df9117121b4cf67cf36d715eee56a7521f47fe0770
5
5
  SHA512:
6
- metadata.gz: c23cfaf18069f8e85b777807e2ceaab25d7a0d58983541044e84791e5f484998d00b5042f1f25222f050f7900d182c371227c03270cd66243c440d02cf98065b
7
- data.tar.gz: 4e809ad13f7cde7f02a3e3ea44c6500e3e430c95e8ae12136b7625bc8ab7a452748e3769adbbef619d033a4346800693b329c40c1f4836594e8c242e4089737f
6
+ metadata.gz: 8948ce194538c052c1761b921a4df485bc99ab5ce9b2e4c12b576d90e10bb6bb1691d7fe111d8ecc6b54e3324d53b8c5c45c0be561d58c4adb4414f08db576b8
7
+ data.tar.gz: 2fcccab9c996fe7a6c79c0090875dd81fca30ba6de130af3cf300d1d745e0212e056afe4ea05a8912191703cddf47800f5e3ea6092e1e751091ecf4a3baffc15
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 1.8.0
6
+
7
+ - Fix deprecation warnings with redis-rb v4.8.0 (https://github.com/ondrejbartas/sidekiq-cron/pull/356)
8
+ - Fix poller affecting Sidekiq scheduled set poller (https://github.com/ondrejbartas/sidekiq-cron/pull/359)
9
+ - Fix default polling interval (https://github.com/ondrejbartas/sidekiq-cron/pull/362)
10
+ - Add italian locale (https://github.com/ondrejbartas/sidekiq-cron/pull/367)
11
+ - Allow disabling of cron polling (https://github.com/ondrejbartas/sidekiq-cron/pull/368)
12
+
5
13
  ## 1.7.0
6
14
 
7
15
  - Enable to use cron notation in natural language (ie `every 30 minutes`) (https://github.com/ondrejbartas/sidekiq-cron/pull/312)
data/README.md CHANGED
@@ -105,7 +105,7 @@ For example: `"*/30 * * * * *"` would schedule a job to run every 30 seconds.
105
105
  Note that if you plan to schedule jobs with second precision you may need to override the default schedule poll interval so it is lower than the interval of your jobs:
106
106
 
107
107
  ```ruby
108
- Sidekiq[:average_scheduled_poll_interval] = 10
108
+ Sidekiq[:cron_poll_interval] = 10
109
109
  ```
110
110
 
111
111
  The default value at time of writing is 30 seconds. See [under the hood](#under-the-hood) for more details.
@@ -332,11 +332,13 @@ Sidekiq-Cron adds itself into this start procedure and starts another thread wit
332
332
  Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can change it by setting:
333
333
 
334
334
  ```ruby
335
- Sidekiq[:average_scheduled_poll_interval] = 10
335
+ Sidekiq[:cron_poll_interval] = 10
336
336
  ```
337
337
 
338
338
  Sidekiq-Cron is safe to use with multiple Sidekiq processes or nodes. It uses a Redis sorted set to determine that only the first process who asks can enqueue scheduled jobs into the queue.
339
339
 
340
+ When running with many Sidekiq processes, the polling can add significant load to Redis. You can disable polling on some processes by setting `Sidekiq[:cron_poll_interval] = 0` on these processes.
341
+
340
342
  ## Contributing
341
343
 
342
344
  **Thanks to all [contributors](https://github.com/ondrejbartas/sidekiq-cron/graphs/contributors), you’re awesome and this wouldn’t be possible without you!**
@@ -465,7 +465,7 @@ module Sidekiq
465
465
  Sidekiq.redis do |conn|
466
466
 
467
467
  # Add to set of all jobs
468
- conn.sadd self.class.jobs_key, redis_key
468
+ conn.sadd self.class.jobs_key, [redis_key]
469
469
 
470
470
  # Add informations for this job!
471
471
  conn.hmset redis_key, *hash_to_redis(to_hash)
@@ -502,7 +502,7 @@ module Sidekiq
502
502
  def destroy
503
503
  Sidekiq.redis do |conn|
504
504
  # Delete from set.
505
- conn.srem self.class.jobs_key, redis_key
505
+ conn.srem self.class.jobs_key, [redis_key]
506
506
 
507
507
  # Delete runned timestamps.
508
508
  conn.del job_enqueued_key
@@ -8,30 +8,34 @@ require 'sidekiq/cron/poller'
8
8
  module Sidekiq
9
9
  module Cron
10
10
  module Launcher
11
+ DEFAULT_POLL_INTERVAL = 30
12
+
11
13
  # Add cron poller to launcher.
12
14
  attr_reader :cron_poller
13
15
 
14
16
  # Add cron poller and execute normal initialize of Sidekiq launcher.
15
17
  def initialize(options)
16
- @cron_poller = Sidekiq::Cron::Poller.new
18
+ options[:cron_poll_interval] = DEFAULT_POLL_INTERVAL if options[:cron_poll_interval].nil?
19
+
20
+ @cron_poller = Sidekiq::Cron::Poller.new(options) if options[:cron_poll_interval] > 0
17
21
  super(options)
18
22
  end
19
23
 
20
24
  # Execute normal run of launcher and run cron poller.
21
25
  def run
22
26
  super
23
- cron_poller.start
27
+ cron_poller.start if @cron_poller
24
28
  end
25
29
 
26
30
  # Execute normal quiet of launcher and quiet cron poller.
27
31
  def quiet
28
- cron_poller.terminate
32
+ cron_poller.terminate if @cron_poller
29
33
  super
30
34
  end
31
35
 
32
36
  # Execute normal stop of launcher and stop cron poller.
33
37
  def stop
34
- cron_poller.terminate
38
+ cron_poller.terminate if @cron_poller
35
39
  super
36
40
  end
37
41
  end
@@ -0,0 +1,23 @@
1
+ it:
2
+ Job: Job
3
+ Cron: Cron
4
+ CronJobs: Cron job
5
+ EnqueueNow: Accoda
6
+ EnableAll: Attiva tutto
7
+ DisableAll: Disattiva tutto
8
+ EnqueueAll: Accoda tutto
9
+ DeleteAll: Cancella tutto
10
+ "Cron string": Cron
11
+ AreYouSureEnqueueCronJobs: Vuoi accodare TUTTI i cron job?
12
+ AreYouSureEnqueueCronJob: "Vuoi accodare il cron job '%{job}'?"
13
+ AreYouSureDeleteCronJobs: Vuoi cancellare TUTTI i cron job?
14
+ AreYouSureDeleteCronJob: "Vuoi cancellare il cron job '%{job}'?"
15
+ NoCronJobsWereFound: Nessun cron job trovato
16
+ Enable: Attiva
17
+ Disable: Disattiva
18
+ "Last enqueued": Ultimo accodamento
19
+ disabled: disattivato
20
+ enabled: attivato
21
+ NoHistoryWereFound: Nessun evento in cronologia
22
+ Description: Descrizione
23
+ Message: Payload
@@ -5,20 +5,15 @@ require 'sidekiq/options'
5
5
 
6
6
  module Sidekiq
7
7
  module Cron
8
- POLL_INTERVAL = Sidekiq::Options[:average_scheduled_poll_interval] || 30
9
-
10
8
  # The Poller checks Redis every N seconds for sheduled cron jobs.
11
9
  class Poller < Sidekiq::Scheduled::Poller
12
- def initialize
13
- Sidekiq.configure_server do
14
- Sidekiq::Options[:poll_interval_average] = POLL_INTERVAL
15
- end
16
-
10
+ def initialize(options = {})
17
11
  if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
18
- # Sidekiq Poller init requires a config argument.
19
- super(Sidekiq)
20
- else
21
12
  super
13
+ else
14
+ # Old version of Sidekiq does not accept a config argument.
15
+ @config = options
16
+ super()
22
17
  end
23
18
  end
24
19
 
@@ -45,6 +40,10 @@ module Sidekiq
45
40
  Sidekiq.logger.error "CRON JOB: #{ex.backtrace.first}"
46
41
  handle_exception(ex) if respond_to?(:handle_exception)
47
42
  end
43
+
44
+ def poll_interval_average(process_count = 1)
45
+ @config[:cron_poll_interval]
46
+ end
48
47
  end
49
48
  end
50
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Cron
5
- VERSION = "1.7.0"
5
+ VERSION = "1.8.0"
6
6
  end
7
7
  end
@@ -42,7 +42,7 @@
42
42
  <td style="<%= style %>"><%= t job.status %></td>
43
43
  <td style="<%= style %>">
44
44
  <a href="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>">
45
- <b><%= job.name %></b>
45
+ <b style="<%= style %>"><%= job.name %></b>
46
46
  </a>
47
47
  <hr style="margin:3px;border:0;">
48
48
  <small>
@@ -929,7 +929,7 @@ describe "Cron Job" do
929
929
  Sidekiq::Cron::Job.create(@args.merge(name: "Test3"))
930
930
 
931
931
  Sidekiq.redis do |conn|
932
- conn.sadd Sidekiq::Cron::Job.jobs_key, "some_other_key"
932
+ conn.sadd Sidekiq::Cron::Job.jobs_key, ["some_other_key"]
933
933
  end
934
934
 
935
935
  assert_equal Sidekiq::Cron::Job.all.size, 3, "All have to return only valid 3 jobs"
@@ -0,0 +1,33 @@
1
+ require './test/test_helper'
2
+
3
+ describe 'Cron launcher' do
4
+ describe 'initialization' do
5
+ before do
6
+ Sidekiq[:cron_poll_interval] = nil
7
+ end
8
+
9
+ it 'initializes poller with default poll interval when not configured' do
10
+ Sidekiq::Cron::Poller.expects(:new).with do |options|
11
+ assert_equal Sidekiq::Cron::Launcher::DEFAULT_POLL_INTERVAL, options[:cron_poll_interval]
12
+ end
13
+
14
+ Sidekiq::Launcher.new(Sidekiq)
15
+ end
16
+
17
+ it 'initializes poller with the configured poll interval' do
18
+ Sidekiq::Cron::Poller.expects(:new).with do |options|
19
+ assert_equal 99, options[:cron_poll_interval]
20
+ end
21
+
22
+ Sidekiq[:cron_poll_interval] = 99
23
+ Sidekiq::Launcher.new(Sidekiq)
24
+ end
25
+
26
+ it 'does not initialize the poller when interval is 0' do
27
+ Sidekiq::Cron::Poller.expects(:new).never
28
+
29
+ Sidekiq[:cron_poll_interval] = 0
30
+ Sidekiq::Launcher.new(Sidekiq)
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-23 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fugit
@@ -156,6 +156,7 @@ files:
156
156
  - lib/sidekiq/cron/launcher.rb
157
157
  - lib/sidekiq/cron/locales/de.yml
158
158
  - lib/sidekiq/cron/locales/en.yml
159
+ - lib/sidekiq/cron/locales/it.yml
159
160
  - lib/sidekiq/cron/locales/ja.yml
160
161
  - lib/sidekiq/cron/locales/pt.yml
161
162
  - lib/sidekiq/cron/locales/ru.yml
@@ -176,6 +177,7 @@ files:
176
177
  - test/unit/fixtures/schedule_hash.yml
177
178
  - test/unit/fixtures/schedule_string.yml
178
179
  - test/unit/job_test.rb
180
+ - test/unit/launcher_test.rb
179
181
  - test/unit/poller_test.rb
180
182
  - test/unit/schedule_loader_test.rb
181
183
  - test/unit/web_extension_test.rb
@@ -198,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
200
  - !ruby/object:Gem::Version
199
201
  version: '0'
200
202
  requirements: []
201
- rubygems_version: 3.1.4
203
+ rubygems_version: 3.1.6
202
204
  signing_key:
203
205
  specification_version: 4
204
206
  summary: Scheduler/Cron for Sidekiq jobs