sidekiq-cron 2.0.0.rc1 → 2.0.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: dce1f7b341e293e80c0b8981c03b24293c2922f4133f62882bcbee62fa3b12d6
4
- data.tar.gz: 210bcfa247b4801bdb86a0d1f5c0454721172abebf0c2e5354be24caee1d6628
3
+ metadata.gz: f6e739f09f2271ea9904b73771ac03701be57e5eae64e3dd3963e772cda7bdb2
4
+ data.tar.gz: 2ab0776fd2dad66b0db9ba38904a3edfbc540e854187f7a59ca205a748b4fd74
5
5
  SHA512:
6
- metadata.gz: cd604c51a98b3b2d1a0af7fdf59afb599f9e9af717043bbbe2816a519be5824694415b59ebd8ec21fa09069798e71bb2d69ae9a62fbf177864f3adcf3c4fc1d3
7
- data.tar.gz: '08ebb6f111498fd8f9b377eed43f17be760caace33185fec69b68e7e5f8ef89d5ee0bd34fe91d714d2c4d5af995e7297909a14e827cf4dce43b7974a859ae50f'
6
+ metadata.gz: 9231cf42e072213083e19c924a09838185faf20d240db195cba87db8f406443ac83172622e4ed89652d09f669e6ce04b7bae3a7836755b28043350c1e2ca056a
7
+ data.tar.gz: 9b63c398a1e129701a20330c5e801f8f36a04651366ed3f38d01061d86033774eb9fe845097af0041f465083d433f4ef783e1be8abf1d083a43f6e3e714c3057
data/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 2.0.0
6
+
7
+ Sidekiq-Cron v2 is here! In this release we refactored some internals, plus:
8
+
9
+ - Review web UI translations for all available locales (https://github.com/sidekiq-cron/sidekiq-cron/pull/506)
10
+ - Fix detection of ActiveJob in Sidekiq v7.3.3+ (https://github.com/sidekiq-cron/sidekiq-cron/pull/510)
11
+ - Add retry job configuration option to set Sidekiq retry job option (https://github.com/sidekiq-cron/sidekiq-cron/pull/509)
12
+
13
+ Please take a look to the RC1 and RC2 changes too if you are coming from the v1.X series.
14
+
15
+ ## 2.0.0.rc2
16
+
17
+ - Remove support for Sidekiq < 6.5 (https://github.com/sidekiq-cron/sidekiq-cron/pull/480)
18
+ - Require at least Fugit >= 1.11.1 (https://github.com/sidekiq-cron/sidekiq-cron/pull/475)
19
+ - Update how Redis values are stored on save (https://github.com/sidekiq-cron/sidekiq-cron/pull/479)
20
+ - Web extension: Add compatibility with Sidekiq 7.3+ and remove inline styles (https://github.com/sidekiq-cron/sidekiq-cron/pull/480)
21
+ - Remove support for old Redis (< 4.2) (https://github.com/sidekiq-cron/sidekiq-cron/pull/490)
22
+ - Ensure date_as_argument option can be set from true to false in Sidekiq Cron jobs (https://github.com/sidekiq-cron/sidekiq-cron/pull/485)
23
+ - Rename `enque!` to `enqueue!` (https://github.com/sidekiq-cron/sidekiq-cron/pull/494)
24
+ - Refactor gem configuration module (https://github.com/sidekiq-cron/sidekiq-cron/pull/495)
25
+
5
26
  ## 2.0.0.rc1
6
27
 
7
28
  - Introduce `Namespacing` (https://github.com/sidekiq-cron/sidekiq-cron/pull/268)
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  🎬 [Introduction video about Sidekiq-Cron by Drifting Ruby](https://www.driftingruby.com/episodes/periodic-tasks-with-sidekiq-cron)
10
10
 
11
- Sidekiq-Cron runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Fugit](https://github.com/floraison/fugit)).
11
+ Sidekiq-Cron runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` or natural language, powered by [Fugit](https://github.com/floraison/fugit)).
12
12
 
13
13
  Checks for new jobs to schedule every 30 seconds and doesn't schedule the same job multiple times when more than one Sidekiq process is running.
14
14
 
@@ -16,10 +16,6 @@ Scheduling jobs are added only when at least one Sidekiq process is running, but
16
16
 
17
17
  If you want to know how scheduling work, check out [under the hood](#under-the-hood).
18
18
 
19
- Works with ActiveJob (Rails 4.2+).
20
-
21
- You don't need Sidekiq PRO, you can use this gem with plain Sidekiq.
22
-
23
19
  ## Changelog
24
20
 
25
21
  Before upgrading to a new version, please read our [Changelog](CHANGELOG.md).
@@ -54,11 +50,12 @@ gem "sidekiq-cron"
54
50
  'namespace' => 'YourNamespace', # groups jobs together in a namespace (Default value is 'default'),
55
51
  'source' => 'dynamic', # source of the job, `schedule`/`dynamic` (default: `dynamic`)
56
52
  'queue' => 'name of queue',
53
+ 'retry' => '5', # Sidekiq (not supported by ActiveJob) number of retries, or false to discard on first failure
57
54
  'args' => '[Array or Hash] of arguments which will be passed to perform method',
58
55
  'date_as_argument' => true, # add the time of execution as last argument of the perform method
59
- 'active_job' => true, # enqueue job through Rails 4.2+ Active Job interface
60
- 'queue_name_prefix' => 'prefix', # Rails 4.2+ Active Job queue with prefix
61
- 'queue_name_delimiter' => '.', # Rails 4.2+ Active Job queue with custom delimiter (default: '_')
56
+ 'active_job' => true, # enqueue job through Active Job interface
57
+ 'queue_name_prefix' => 'prefix', # Active Job queue with prefix
58
+ 'queue_name_delimiter' => '.', # Active Job queue with custom delimiter (default: '_')
62
59
  'description' => 'A sentence describing what work this job performs'
63
60
  'status' => 'disabled' # default: enabled
64
61
  }
@@ -66,6 +63,23 @@ gem "sidekiq-cron"
66
63
 
67
64
  **NOTE** The `status` of a job does not get changed in Redis when a job gets reloaded unless the `status` property is explicitly set.
68
65
 
66
+ ### Configuration
67
+
68
+ All configuration options:
69
+
70
+ ```ruby
71
+ Sidekiq::Cron.configure do |config|
72
+ config.cron_poll_interval = 10 # Default is 30
73
+ config.cron_schedule_file = 'config/my_schedule.yml' # Default is 'config/schedule.yml'
74
+ config.cron_history_size = 20 # Default is 10
75
+ config.default_namespace = 'statistics' # Default is 'default'
76
+ config.natural_cron_parsing_mode = :strict # Default is :single
77
+ config.reschedule_grace_period = 300 # Default is 60
78
+ end
79
+ ```
80
+
81
+ If you are using Rails, you should add the above block inside an initializer (`config/initializers/sidekiq-cron.rb`).
82
+
69
83
  ### Time, cron and Sidekiq-Cron
70
84
 
71
85
  For testing your cron notation you can use [crontab.guru](https://crontab.guru).
@@ -79,9 +93,9 @@ like this `'0 22 * * 1-5 America/Chicago'`.
79
93
 
80
94
  #### Natural-language formats
81
95
 
82
- Since sidekiq-cron `v1.7.0`, you can use the natural-language formats supported by Fugit, such as:
96
+ Since Sidekiq-Cron `v1.7.0`, you can use the natural-language formats supported by Fugit, such as:
83
97
 
84
- ```rb
98
+ ```ruby
85
99
  "every day at five" # => '0 5 * * *'
86
100
  "every 3 hours" # => '0 */3 * * *'
87
101
  ```
@@ -122,7 +136,7 @@ Ex. `every day at 3:15 and 4:30`
122
136
 
123
137
  #### Second-precision (sub-minute) cronlines
124
138
 
125
- In addition to the standard 5-parameter cronline format, sidekiq-cron supports scheduling jobs with second-precision using a modified 6-parameter cronline format:
139
+ In addition to the standard 5-parameter cronline format, Sidekiq-Cron supports scheduling jobs with second-precision using a modified 6-parameter cronline format:
126
140
 
127
141
  `Seconds Minutes Hours Days Months DayOfWeek`
128
142
 
@@ -131,7 +145,9 @@ For example: `"*/30 * * * * *"` would schedule a job to run every 30 seconds.
131
145
  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:
132
146
 
133
147
  ```ruby
134
- Sidekiq::Options[:cron_poll_interval] = 10
148
+ Sidekiq::Cron.configure do |config|
149
+ config.cron_poll_interval = 10
150
+ end
135
151
  ```
136
152
 
137
153
  The default value at time of writing is 30 seconds. See [under the hood](#under-the-hood) for more details.
@@ -142,9 +158,7 @@ The default value at time of writing is 30 seconds. See [under the hood](#under-
142
158
 
143
159
  When not giving a namespace, the `default` one will be used.
144
160
 
145
- In the case you'd like to change this value, create a new initializer like so:
146
-
147
- `config/initializers/sidekiq-cron.rb`:
161
+ In the case you'd like to change this value, you can change it via the following configuration flag:
148
162
 
149
163
  ```ruby
150
164
  Sidekiq::Cron.configure do |config|
@@ -222,7 +236,7 @@ class ExampleJob < ActiveJob::Base
222
236
  end
223
237
  ```
224
238
 
225
- For Active jobs you can use `symbolize_args: true` in `Sidekiq::Cron::Job.create` or in Hash configuration,
239
+ For Active Job you can use `symbolize_args: true` in `Sidekiq::Cron::Job.create` or in Hash configuration,
226
240
  which will ensure that arguments you are passing to it will be symbolized when passed back to `perform` method in worker.
227
241
 
228
242
  ### Adding Cron jobs
@@ -261,7 +275,7 @@ end
261
275
 
262
276
  Use ActiveRecord models as arguments:
263
277
 
264
- ```rb
278
+ ```ruby
265
279
  class Person < ApplicationRecord
266
280
  end
267
281
 
@@ -325,7 +339,7 @@ Sidekiq::Cron::Job.load_from_array! array
325
339
 
326
340
  ### Loading jobs from schedule file
327
341
 
328
- You can also load multiple jobs from a YAML (same notation as `Resque-scheduler`) file:
342
+ You can also load multiple jobs from a YAML file:
329
343
 
330
344
  ```yaml
331
345
  # config/schedule.yml
@@ -346,24 +360,31 @@ second_job:
346
360
  There are multiple ways to load the jobs from a YAML file
347
361
 
348
362
  1. The gem will automatically load the jobs mentioned in `config/schedule.yml` file (it supports ERB)
349
- 2. When you want to load jobs from a different filename, mention the filename in sidekiq configuration, i.e. `cron_schedule_file: "config/users_schedule.yml"`
363
+ 2. When you want to load jobs from a different filename, mention the filename in Sidekiq configuration as follows:
364
+
365
+ ```ruby
366
+ Sidekiq::Cron.configure do |config|
367
+ config.cron_schedule_file = "config/users_schedule.yml"
368
+ end
369
+ ```
370
+
350
371
  3. Load the file manually as follows:
351
372
 
352
- ```ruby
353
- # config/initializers/sidekiq.rb
373
+ ```ruby
374
+ # config/initializers/sidekiq.rb
354
375
 
355
- Sidekiq.configure_server do |config|
356
- config.on(:startup) do
357
- schedule_file = "config/users_schedule.yml"
376
+ Sidekiq.configure_server do |config|
377
+ config.on(:startup) do
378
+ schedule_file = "config/users_schedule.yml"
358
379
 
359
- if File.exist?(schedule_file)
360
- schedule = YAML.load_file(schedule_file)
380
+ if File.exist?(schedule_file)
381
+ schedule = YAML.load_file(schedule_file)
361
382
 
362
- Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
383
+ Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
384
+ end
385
+ end
363
386
  end
364
- end
365
- end
366
- ```
387
+ ```
367
388
 
368
389
  ### Finding jobs
369
390
 
@@ -409,7 +430,7 @@ job.status
409
430
  # => enabled/disabled
410
431
 
411
432
  # enqueue job right now!
412
- job.enque!
433
+ job.enqueue!
413
434
  ```
414
435
 
415
436
  ### Schedule vs Dynamic jobs
@@ -448,14 +469,14 @@ Sidekiq-Cron adds itself into this start procedure and starts another thread wit
448
469
  Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can change it by setting:
449
470
 
450
471
  ```ruby
451
- Sidekiq::Options[:cron_poll_interval] = 10
472
+ Sidekiq::Cron.configure do |config|
473
+ config.cron_poll_interval = 10
474
+ end
452
475
  ```
453
476
 
454
- When sidekiq (and sidekiq-cron) is not used in zero-downtime deployments, after the deployment is done sidekiq-cron starts to catch up. It will consider older jobs that missed their schedules during that time. By default, only jobs that should have started less than 1 minute ago are considered. This is problematic for some jobs, e.g., jobs that run once a day. If on average sidekiq is shut down for 10 minutes during deployments, you can configure sidekiq-cron to consider jobs that were about to be scheduled during that time:
477
+ When Sidekiq (and Sidekiq-Cron) is not used in zero-downtime deployments, after the deployment is done Sidekiq-Cron starts to catch up. It will consider older jobs that missed their schedules during that time. By default, only jobs that should have started less than 1 minute ago are considered. This is problematic for some jobs, e.g., jobs that run once a day. If on average Sidekiq is shut down for 10 minutes during deployments, you can configure Sidekiq-Cron to consider jobs that were about to be scheduled during that time:
455
478
 
456
479
  ```ruby
457
- # config/initializers/sidekiq-cron.rb
458
-
459
480
  Sidekiq::Cron.configure do |config|
460
481
  config.reschedule_grace_period = 600 # 10 minutes in seconds
461
482
  end
@@ -463,7 +484,13 @@ end
463
484
 
464
485
  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.
465
486
 
466
- When running with many Sidekiq processes, the polling can add significant load to Redis. You can disable polling on some processes by setting `Sidekiq::Options[:cron_poll_interval] = 0` on these processes.
487
+ When running with many Sidekiq processes, the polling can add significant load to Redis. You can disable polling on some processes by setting:
488
+
489
+ ```ruby
490
+ Sidekiq::Cron.configure do |config|
491
+ config.cron_poll_interval = 0
492
+ end
493
+ ```
467
494
 
468
495
  ## Contributing
469
496
 
@@ -487,21 +514,21 @@ $ bundle exec rake test
487
514
 
488
515
  ### Using Docker
489
516
 
490
- [Docker](https://www.docker.com) allows you to run things in containers easing the development process.
491
-
492
517
  This project uses [Docker Compose](https://docs.docker.com/compose/) in order to orchestrate containers and get the test suite running on you local machine, and here you find the commands to run in order to get a complete environment to build and test this gem:
493
518
 
494
519
  1. Build the Docker image (only the first time):
495
520
  ```
496
521
  docker compose -f docker/docker-compose.yml build
497
522
  ```
523
+
498
524
  2. Run the test suite:
499
525
  ```
500
526
  docker compose -f docker/docker-compose.yml run --rm tests
501
527
  ```
528
+
502
529
  _This command will download the first time the project's dependencies (Redis so far), create the containers and run the default command to run the tests._
503
530
 
504
- #### Running other commands
531
+ **Running other commands**
505
532
 
506
533
  In the case you need to run a command in the gem's container, you would do it like so:
507
534
 
@@ -510,7 +537,7 @@ docker compose -f docker/docker-compose.yml run --rm tests <HERE IS YOUR COMMAND
510
537
  ```
511
538
  _Note that `tests` is the Docker Compose service name defined in the `docker/docker-compose.yml` file._
512
539
 
513
- #### Running a single test file
540
+ **Running a single test file**
514
541
 
515
542
  Given you only want to run the tests from the `test/unit/web_extension_test.rb` file, you need to pass its path with the `TEST` env variable, so here is the command:
516
543
 
@@ -3,9 +3,7 @@
3
3
  require 'fugit'
4
4
  require 'cronex'
5
5
  require 'globalid'
6
- require 'sidekiq'
7
6
  require 'sidekiq/cron/support'
8
- require 'sidekiq/options'
9
7
 
10
8
  module Sidekiq
11
9
  module Cron
@@ -16,9 +14,6 @@ module Sidekiq
16
14
  # Time format for enqueued jobs.
17
15
  LAST_ENQUEUE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z'
18
16
 
19
- # Use the exists? method if we're on a newer version of Redis.
20
- REDIS_EXISTS_METHOD = Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new("7.0.0") || Gem.loaded_specs['redis'].version < Gem::Version.new('4.2') ? :exists : :exists?
21
-
22
17
  # Use serialize/deserialize key of GlobalID.
23
18
  GLOBALID_KEY = "_sc_globalid"
24
19
 
@@ -66,6 +61,7 @@ module Sidekiq
66
61
  @message = args["message"]
67
62
  message_data = Sidekiq.load_json(@message) || {}
68
63
  @queue = message_data['queue'] || "default"
64
+ @retry = message_data['retry']
69
65
  elsif @klass
70
66
  message_data = {
71
67
  "class" => @klass.to_s,
@@ -77,7 +73,7 @@ module Sidekiq
77
73
  klass_data = get_job_class_options(@klass)
78
74
  message_data = klass_data.merge(message_data)
79
75
 
80
- # Override queue if set in config,
76
+ # Override queue and retry if set in config,
81
77
  # only if message is hash - can be string (dumped JSON).
82
78
  if args['queue']
83
79
  @queue = message_data['queue'] = args['queue']
@@ -85,6 +81,12 @@ module Sidekiq
85
81
  @queue = message_data['queue'] || "default"
86
82
  end
87
83
 
84
+ if args['retry'] != nil
85
+ @retry = message_data['retry'] = args['retry']
86
+ else
87
+ @retry = message_data['retry']
88
+ end
89
+
88
90
  @message = message_data
89
91
  end
90
92
 
@@ -92,7 +94,7 @@ module Sidekiq
92
94
  end
93
95
 
94
96
  # Crucial part of whole enqueuing job.
95
- def should_enque? time
97
+ def should_enqueue? time
96
98
  return false unless status == "enabled"
97
99
  return false if past_scheduled_time?(time)
98
100
  return false if enqueued_after?(time)
@@ -105,23 +107,23 @@ module Sidekiq
105
107
 
106
108
  # Remove previous information about run times,
107
109
  # this will clear Redis and make sure that Redis will not overflow with memory.
108
- def remove_previous_enques time
110
+ def remove_previous_enqueues time
109
111
  Sidekiq.redis do |conn|
110
112
  conn.zremrangebyscore(job_enqueued_key, 0, "(#{(time.to_f - REMEMBER_THRESHOLD).to_s}")
111
113
  end
112
114
  end
113
115
 
114
116
  # Test if job should be enqueued.
115
- def test_and_enque_for_time! time
116
- if should_enque?(time)
117
- enque!
117
+ def test_and_enqueue_for_time! time
118
+ if should_enqueue?(time)
119
+ enqueue!
118
120
 
119
- remove_previous_enques(time)
121
+ remove_previous_enqueues(time)
120
122
  end
121
123
  end
122
124
 
123
125
  # Enqueue cron job to queue.
124
- def enque! time = Time.now.utc
126
+ def enqueue! time = Time.now.utc
125
127
  @last_enqueue_time = time
126
128
 
127
129
  klass_const =
@@ -152,7 +154,7 @@ module Sidekiq
152
154
  end
153
155
 
154
156
  def is_active_job?(klass = nil)
155
- @active_job || defined?(ActiveJob::Base) && (klass || Sidekiq::Cron::Support.constantize(@klass.to_s)) < ActiveJob::Base
157
+ @active_job || defined?(::ActiveJob::Base) && (klass || Sidekiq::Cron::Support.constantize(@klass.to_s)) < ::ActiveJob::Base
156
158
  rescue NameError
157
159
  false
158
160
  end
@@ -171,7 +173,7 @@ module Sidekiq
171
173
  end
172
174
 
173
175
  def enqueue_sidekiq_worker(klass_const)
174
- klass_const.set(queue: queue_name_with_prefix).perform_async(*enqueue_args)
176
+ klass_const.set(queue: queue_name_with_prefix, retry: @retry).perform_async(*enqueue_args)
175
177
  end
176
178
 
177
179
  # Sidekiq worker message.
@@ -186,16 +188,16 @@ module Sidekiq
186
188
 
187
189
  if !"#{@active_job_queue_name_delimiter}".empty?
188
190
  queue_name_delimiter = @active_job_queue_name_delimiter
189
- elsif defined?(ActiveJob::Base) && defined?(ActiveJob::Base.queue_name_delimiter) && !ActiveJob::Base.queue_name_delimiter.empty?
190
- queue_name_delimiter = ActiveJob::Base.queue_name_delimiter
191
+ elsif defined?(::ActiveJob::Base) && defined?(::ActiveJob::Base.queue_name_delimiter) && !::ActiveJob::Base.queue_name_delimiter.empty?
192
+ queue_name_delimiter = ::ActiveJob::Base.queue_name_delimiter
191
193
  else
192
194
  queue_name_delimiter = '_'
193
195
  end
194
196
 
195
197
  if !"#{@active_job_queue_name_prefix}".empty?
196
198
  queue_name = "#{@active_job_queue_name_prefix}#{queue_name_delimiter}#{@queue}"
197
- elsif defined?(ActiveJob::Base) && defined?(ActiveJob::Base.queue_name_prefix) && !"#{ActiveJob::Base.queue_name_prefix}".empty?
198
- queue_name = "#{ActiveJob::Base.queue_name_prefix}#{queue_name_delimiter}#{@queue}"
199
+ elsif defined?(::ActiveJob::Base) && defined?(::ActiveJob::Base.queue_name_prefix) && !"#{::ActiveJob::Base.queue_name_prefix}".empty?
200
+ queue_name = "#{::ActiveJob::Base.queue_name_prefix}#{queue_name_delimiter}#{@queue}"
199
201
  else
200
202
  queue_name = @queue
201
203
  end
@@ -413,7 +415,7 @@ module Sidekiq
413
415
 
414
416
  # Export job data to hash.
415
417
  def to_hash
416
- hash = {
418
+ {
417
419
  name: @name,
418
420
  namespace: @namespace,
419
421
  klass: @klass.to_s,
@@ -421,20 +423,16 @@ module Sidekiq
421
423
  description: @description,
422
424
  source: @source,
423
425
  args: @args.is_a?(String) ? @args : Sidekiq.dump_json(@args || []),
426
+ date_as_argument: date_as_argument? ? "1" : "0",
424
427
  message: @message.is_a?(String) ? @message : Sidekiq.dump_json(@message || {}),
425
428
  status: @status,
426
429
  active_job: @active_job ? "1" : "0",
427
430
  queue_name_prefix: @active_job_queue_name_prefix,
428
431
  queue_name_delimiter: @active_job_queue_name_delimiter,
432
+ retry: @retry.nil? || @retry.is_a?(Numeric) ? @retry : @retry.to_s,
429
433
  last_enqueue_time: serialized_last_enqueue_time,
430
434
  symbolize_args: symbolize_args? ? "1" : "0",
431
435
  }
432
-
433
- if date_as_argument?
434
- hash.merge!(date_as_argument: "1")
435
- end
436
-
437
- hash
438
436
  end
439
437
 
440
438
  def errors
@@ -447,6 +445,7 @@ module Sidekiq
447
445
 
448
446
  errors << "'name' must be set" if @name.nil? || @name.size == 0
449
447
  errors << "'namespace' must be set" if @namespace.nil? || @namespace.size == 0
448
+ errors << "'namespace' cannot be '*'" if @namespace == "*"
450
449
 
451
450
  if @cron.nil? || @cron.size == 0
452
451
  errors << "'cron' must be set"
@@ -482,14 +481,19 @@ module Sidekiq
482
481
  conn.sadd self.class.jobs_key(@namespace), [redis_key]
483
482
 
484
483
  # Add information for this job!
485
- conn.hset redis_key, to_hash.transform_values! { |v| v || '' }
484
+ conn.hset redis_key, to_hash.transform_values! { |v| v || '' }.flatten
486
485
 
487
- # Add information about last time! - don't enque right after scheduler poller starts!
486
+ # Add information about last time! - don't enqueue right after scheduler poller starts!
488
487
  time = Time.now.utc
489
- exists = conn.public_send(REDIS_EXISTS_METHOD, job_enqueued_key)
490
- conn.zadd(job_enqueued_key, time.to_f.to_s, formatted_last_time(time).to_s) unless exists == true || exists == 1
488
+ exists = conn.exists(job_enqueued_key)
489
+
490
+ unless exists == true || exists == 1
491
+ conn.zadd(job_enqueued_key, time.to_f.to_s, formatted_last_time(time).to_s)
492
+ Sidekiq.logger.info { "Cron Jobs - added job with name #{@name} in the namespace #{@namespace}" }
493
+ end
491
494
  end
492
- Sidekiq.logger.info { "Cron Jobs - added job with name #{@name} in the namespace #{@namespace}" }
495
+
496
+ true
493
497
  end
494
498
 
495
499
  def save_last_enqueue_time
@@ -505,7 +509,7 @@ module Sidekiq
505
509
  enqueued: @last_enqueue_time
506
510
  }
507
511
 
508
- @history_size ||= (Sidekiq::Options[:cron_history_size] || 10).to_i - 1
512
+ @history_size ||= Sidekiq::Cron.configuration.cron_history_size.to_i - 1
509
513
  Sidekiq.redis do |conn|
510
514
  conn.lpush jid_history_key,
511
515
  Sidekiq.dump_json(jid_history)
@@ -572,7 +576,7 @@ module Sidekiq
572
576
 
573
577
  def self.exists?(name, namespace = Sidekiq::Cron.configuration.default_namespace)
574
578
  out = Sidekiq.redis do |conn|
575
- conn.public_send(REDIS_EXISTS_METHOD, redis_key(name, namespace))
579
+ conn.exists(redis_key(name, namespace))
576
580
  end
577
581
 
578
582
  [true, 1].include?(out)
@@ -1,5 +1,3 @@
1
- require 'sidekiq/cron/poller'
2
-
3
1
  # For Cron we need to add some methods to Launcher
4
2
  # so look at the code below.
5
3
  #
@@ -8,14 +6,13 @@ require 'sidekiq/cron/poller'
8
6
  module Sidekiq
9
7
  module Cron
10
8
  module Launcher
11
- DEFAULT_POLL_INTERVAL = 30
12
9
 
13
10
  # Add cron poller to launcher.
14
11
  attr_reader :cron_poller
15
12
 
16
13
  # Add cron poller and execute normal initialize of Sidekiq launcher.
17
14
  def initialize(config, **kwargs)
18
- config[:cron_poll_interval] = DEFAULT_POLL_INTERVAL if config[:cron_poll_interval].nil?
15
+ config[:cron_poll_interval] = Sidekiq::Cron.configuration.cron_poll_interval.to_i
19
16
 
20
17
  @cron_poller = Sidekiq::Cron::Poller.new(config) if config[:cron_poll_interval] > 0
21
18
  super
@@ -1,13 +1,22 @@
1
1
  de:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Sind Sie sicher, dass sie den Cronjob %{job} löschen wollen?
3
+ AreYouSureDeleteCronJobs: Sind Sie sicher, dass Sie ALLE Cron-Jobs löschen möchten?
4
+ AreYouSureEnqueueCronJob: Sind Sie sicher, dass Sie den %{job} Cron-Job einreihen möchten?
5
+ AreYouSureEnqueueCronJobs: Sind Sie sicher, dass Sie ALLE Cron-Jobs einreihen möchten?
3
6
  Cron: Cron
4
7
  CronJobs: Cronjobs
8
+ CronString: Cron
9
+ DeleteAll: Alle löschen
10
+ Description: Beschreibung
11
+ Disable: Deaktivieren
12
+ DisableAll: Alle deaktivieren
13
+ Enable: Aktivieren
14
+ EnableAll: Alle aktivieren
15
+ EnqueueAll: Alle einreihen
5
16
  EnqueueNow: In Warteschlange
6
- 'Cron string': Cron
7
- AreYouSureDeleteCronJob: Sind Sie sicher, dass sie den Cronjob %{job} löschen wollen?
17
+ Job: Job
18
+ LastEnqueued: Eingereiht
8
19
  NoCronJobsWereFound: Keine Cronjobs gefunden
9
- Enable: Aktivieren
10
- Disable: Deaktivieren
11
- 'Last enqueued': Eingereiht
20
+ NoHistoryWereFound: Keine Historie gefunden
12
21
  disabled: deaktiviert
13
22
  enabled: aktiviert
@@ -1,22 +1,22 @@
1
1
  en:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Are you sure you want to delete the %{job} cron job?
3
+ AreYouSureDeleteCronJobs: Are you sure you want to delete ALL cron jobs?
4
+ AreYouSureEnqueueCronJob: Are you sure you want to enqueue the %{job} cron job?
5
+ AreYouSureEnqueueCronJobs: Are you sure you want to enqueue ALL cron jobs?
3
6
  Cron: Cron
4
7
  CronJobs: Cron Jobs
5
- EnqueueNow: Enqueue Now
6
- EnableAll: Enable All
8
+ CronString: Cron
9
+ DeleteAll: Delete All
10
+ Description: Description
11
+ Disable: Disable
7
12
  DisableAll: Disable All
13
+ Enable: Enable
14
+ EnableAll: Enable All
8
15
  EnqueueAll: Enqueue All
9
- DeleteAll: Delete All
10
- 'Cron string': Cron
11
- AreYouSureEnqueueCronJobs: Are you sure you want to enqueue ALL cron jobs?
12
- AreYouSureEnqueueCronJob: Are you sure you want to enqueue the %{job} cron job?
13
- AreYouSureDeleteCronJobs: Are you sure you want to delete ALL cron jobs?
14
- AreYouSureDeleteCronJob: Are you sure you want to delete the %{job} cron job?
16
+ EnqueueNow: Enqueue Now
17
+ Job: Job
18
+ LastEnqueued: Last enqueued
15
19
  NoCronJobsWereFound: No cron jobs were found
16
- Enable: Enable
17
- Disable: Disable
18
- 'Last enqueued': Last enqueued
20
+ NoHistoryWereFound: No history were found
19
21
  disabled: disabled
20
22
  enabled: enabled
21
- NoHistoryWereFound: No history were found
22
- Description: Description
@@ -1,22 +1,22 @@
1
1
  id:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Apakah Anda yakin ingin menghapus cron job %{job}?
3
+ AreYouSureDeleteCronJobs: Apakah Anda yakin ingin menghapus SEMUA cron job?
4
+ AreYouSureEnqueueCronJob: Apakah Anda yakin ingin menambahkan cron job %{job} ke antrian?
5
+ AreYouSureEnqueueCronJobs: Apakah Anda yakin ingin menambahkan SEMUA cron job ke antrian?
3
6
  Cron: Cron
4
- CronJobs: Cron Job
5
- EnqueueNow: Tambahkan ke Antrian Sekarang
6
- EnableAll: Aktifkan Semua
7
+ CronJobs: Cron Jobs
8
+ CronString: Cron
9
+ DeleteAll: Hapus Semua
10
+ Description: Deskripsi
11
+ Disable: Nonaktifkan
7
12
  DisableAll: Nonaktifkan Semua
13
+ Enable: Aktifkan
14
+ EnableAll: Aktifkan Semua
8
15
  EnqueueAll: Tambahkan Semua ke Antrian
9
- DeleteAll: Hapus Semua
10
- 'Cron string': Cron string
11
- AreYouSureEnqueueCronJobs: Apakah Anda yakin ingin menambahkan SEMUA cron job ke antrian?
12
- AreYouSureEnqueueCronJob: Apakah Anda yakin ingin menambahkan cron job %{job} ke antrian?
13
- AreYouSureDeleteCronJobs: Apakah Anda yakin ingin menghapus SEMUA cron job?
14
- AreYouSureDeleteCronJob: Apakah Anda yakin ingin menghapus cron job %{job}?
16
+ EnqueueNow: Tambahkan ke Antrian Sekarang
17
+ Job: Job
18
+ LastEnqueued: Terakhir kali ditambahkan ke antrian
15
19
  NoCronJobsWereFound: Tidak ada cron job
16
- Enable: Aktifkan
17
- Disable: Nonaktifkan
18
- 'Last enqueued': Terakhir kali ditambahkan ke antrian
20
+ NoHistoryWereFound: Tidak ada riwayat
19
21
  disabled: dinonaktifkan
20
22
  enabled: diaktifkan
21
- NoHistoryWereFound: Tidak ada riwayat
22
- Description: Deskripsi
@@ -1,23 +1,22 @@
1
1
  it:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Vuoi cancellare il cron job '%{job}'?
3
+ AreYouSureDeleteCronJobs: Vuoi cancellare TUTTI i cron job?
4
+ AreYouSureEnqueueCronJob: Vuoi accodare il cron job '%{job}'?
5
+ AreYouSureEnqueueCronJobs: Vuoi accodare TUTTI i cron job?
3
6
  Cron: Cron
4
- CronJobs: Cron job
5
- EnqueueNow: Accoda
6
- EnableAll: Attiva tutto
7
+ CronJobs: Cron Jobs
8
+ CronString: Cron
9
+ DeleteAll: Cancella tutto
10
+ Description: Descrizione
11
+ Disable: Disattiva
7
12
  DisableAll: Disattiva tutto
13
+ Enable: Attiva
14
+ EnableAll: Attiva tutto
8
15
  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}'?"
16
+ EnqueueNow: Accoda
17
+ Job: Job
18
+ LastEnqueued: Ultimo accodamento
15
19
  NoCronJobsWereFound: Nessun cron job trovato
16
- Enable: Attiva
17
- Disable: Disattiva
18
- "Last enqueued": Ultimo accodamento
20
+ NoHistoryWereFound: Nessun evento in cronologia
19
21
  disabled: disattivato
20
22
  enabled: attivato
21
- NoHistoryWereFound: Nessun evento in cronologia
22
- Description: Descrizione
23
- Message: Payload