sidekiq-cron 1.4.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: 437dc35edb85224f5e77eaa73be4adac923adb313f755f3029a4037e92a9c523
4
- data.tar.gz: 517c8dd23943edb6c1e6e3059b4b6f7044ff85d13594447dbb097ff7438afc63
3
+ metadata.gz: 7df934577b0740b3e977ffd0e361f6333de6958921659d78bf4c4e4a0015aad9
4
+ data.tar.gz: 6ae3317c56ff984bf0b651df9117121b4cf67cf36d715eee56a7521f47fe0770
5
5
  SHA512:
6
- metadata.gz: 8d943877a3c9577b060ccbc86fca6e256ac6e12e7ab4ef5428091960d82d119b8087264b3fd20afcd2a191dc722f42deab5701557aa5d1fd9e0f2cfe10357b26
7
- data.tar.gz: 39f3b04c168c250f0273796fb1c6f20947114d92030d60fed74d2c5087ee401b35f0b3e1fdea00a6c7eac9116d76204ce439dae7a5ba965b60978034ae472d38
6
+ metadata.gz: 8948ce194538c052c1761b921a4df485bc99ab5ce9b2e4c12b576d90e10bb6bb1691d7fe111d8ecc6b54e3324d53b8c5c45c0be561d58c4adb4414f08db576b8
7
+ data.tar.gz: 2fcccab9c996fe7a6c79c0090875dd81fca30ba6de130af3cf300d1d745e0212e056afe4ea05a8912191703cddf47800f5e3ea6092e1e751091ecf4a3baffc15
@@ -2,6 +2,35 @@
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
+
13
+ ## 1.7.0
14
+
15
+ - Enable to use cron notation in natural language (ie `every 30 minutes`) (https://github.com/ondrejbartas/sidekiq-cron/pull/312)
16
+ - Fix `date_as_argument` feature to add timestamp argument at every cron job execution (https://github.com/ondrejbartas/sidekiq-cron/pull/329)
17
+ - Introduce `Sidekiq::Options` to centralize reading/writing options from different Sidekiq versions (https://github.com/ondrejbartas/sidekiq-cron/pull/341)
18
+ - Make auto schedule loading compatible with Array format (https://github.com/ondrejbartas/sidekiq-cron/pull/345)
19
+
20
+ ## 1.6.0
21
+
22
+ - Adds support for auto-loading the `config/schedule.yml` file (https://github.com/ondrejbartas/sidekiq-cron/pull/337)
23
+ - Fix `Sidekiq.options` deprecation warning (https://github.com/ondrejbartas/sidekiq-cron/pull/338)
24
+
25
+ ## 1.5.1
26
+
27
+ - Fixes an issue that prevented the gem to work in previous Sidekiq versions (https://github.com/ondrejbartas/sidekiq-cron/pull/335)
28
+
29
+ ## 1.5.0
30
+
31
+ - Integrate Sidekiq v6.5 breaking changes (https://github.com/ondrejbartas/sidekiq-cron/pull/331)
32
+ - Add portuguese translations (https://github.com/ondrejbartas/sidekiq-cron/pull/332)
33
+
5
34
  ## 1.4.0
6
35
 
7
36
  - Fix buttons order in job show view (https://github.com/ondrejbartas/sidekiq-cron/pull/302)
@@ -16,7 +45,6 @@ All notable changes to this project will be documented in this file.
16
45
 
17
46
  - Add confirmation dialog when enquing jobs from UI
18
47
  - Start to support Sidekiq `average_scheduled_poll_interval` option (replaced `poll_interval`)
19
- - Enable to use latest fugit to parse cron notation alowing use of natural language (ie `"every 30 minutes"`)
20
48
  - Fix deprecation warning for Redis 4.6.x
21
49
  - Fix different response from Redis#exists in different Redis versions
22
50
  - All PRs:
@@ -38,7 +66,7 @@ All notable changes to this project will be documented in this file.
38
66
 
39
67
  - Updated readme
40
68
  - Fix unit tests - changed argument error when getting invalid cron format
41
- - When fallbacking old job enqueued time use `Time.parse` without format (so ruby can decide best method to parse it)
69
+ - When fallbacking old job enqueued time use `Time.parse` without format (so Ruby can decide best method to parse it)
42
70
  - Add option `date_as_argument` which will add to your job arguments on last place `Time.now.to_f` when it was eneuqued
43
71
  - Add option `description` which will allow you to add notes to your jobs so in web view you can see it
44
72
  - Fixed translations
@@ -62,8 +90,8 @@ All notable changes to this project will be documented in this file.
62
90
  - Fix poller to enqueu all jobs in poll start time
63
91
  - Add performance test for enqueue of jobs (10 000 jobs in less than 19s)
64
92
  - Fix problem with default queue
65
- - Remove redis-namespace from dependencies
66
- - Update ruby versions in travis
93
+ - Remove `redis-namespace` from dependencies
94
+ - Update Ruby versions in Travis
67
95
 
68
96
  ## 0.5.0
69
97
 
@@ -75,7 +103,7 @@ All notable changes to this project will be documented in this file.
75
103
  - Add Russian locale
76
104
  - User Rack.env in tests
77
105
  - Faster enqueue of jobs
78
- - Permit to use ActiveJob::Base.queue_name_delimiter
106
+ - Permit to use `ActiveJob::Base.queue_name_delimiter`
79
107
  - Fix problem with multiple times enqueue #84
80
108
  - Fix problem with enqueue of unknown class
81
109
 
data/README.md CHANGED
@@ -27,7 +27,7 @@ Please be aware that Sidekiq-Cron < 1.0 was relying on rufus-scheduler < 3.5. Us
27
27
 
28
28
  ## Changelog
29
29
 
30
- Before upgrading to a new version, please read our [Changelog](Changes.md).
30
+ Before upgrading to a new version, please read our [Changelog](CHANGELOG.md).
31
31
 
32
32
  ## Installation
33
33
 
@@ -35,6 +35,7 @@ Before upgrading to a new version, please read our [Changelog](Changes.md).
35
35
 
36
36
  - Redis 2.8 or greater is required (Redis 3.0.3 or greater is recommended for large scale use)
37
37
  - Sidekiq 4.2 or greater is required (for Sidekiq < 4 use version sidekiq-cron 0.3.1)
38
+ - Sidekiq 6.5 requires Sidekiq-Cron 1.5+
38
39
 
39
40
  Install the gem:
40
41
 
@@ -45,7 +46,7 @@ $ gem install sidekiq-cron
45
46
  Or add to your `Gemfile` and run `bundle install`:
46
47
 
47
48
  ```ruby
48
- gem "sidekiq-cron", "~> 1.3"
49
+ gem "sidekiq-cron"
49
50
  ```
50
51
 
51
52
  **NOTE** If you are not using Rails, you need to add `require 'sidekiq-cron'` somewhere after `require 'sidekiq'`.
@@ -63,10 +64,10 @@ gem "sidekiq-cron", "~> 1.3"
63
64
  'queue' => 'name of queue',
64
65
  'args' => '[Array or Hash] of arguments which will be passed to perform method',
65
66
  'date_as_argument' => true, # add the time of execution as last argument of the perform method
66
- 'active_job' => true, # enqueue job through rails 4.2+ active job interface
67
- 'queue_name_prefix' => 'prefix', # rails 4.2+ active job queue with prefix
68
- 'queue_name_delimiter' => '.', # rails 4.2+ active job queue with custom delimiter
69
- 'description' => 'A sentence describing what work this job performs.'
67
+ 'active_job' => true, # enqueue job through Rails 4.2+ Active Job interface
68
+ 'queue_name_prefix' => 'prefix', # Rails 4.2+ Active Job queue with prefix
69
+ 'queue_name_delimiter' => '.', # Rails 4.2+ Active Job queue with custom delimiter
70
+ 'description' => 'A sentence describing what work this job performs'
70
71
  'status' => 'disabled' # default: enabled
71
72
  }
72
73
  ```
@@ -82,6 +83,17 @@ If using Rails, this is evaluated against the timezone configured in Rails, othe
82
83
  If you want to have your jobs enqueued based on a different time zone you can specify a timezone in the cronline,
83
84
  like this `'0 22 * * 1-5 America/Chicago'`.
84
85
 
86
+ #### Natural-language formats
87
+
88
+ Since sidekiq-cron `v1.7.0`, you can use the natural-language formats supported by Fugit, such as:
89
+
90
+ ```rb
91
+ "every day at five" # => '0 5 * * *'
92
+ "every 3 hours" # => '0 */3 * * *'
93
+ ```
94
+
95
+ See [the relevant part of Fugit documentation](https://github.com/floraison/fugit#fugitnat) for details.
96
+
85
97
  #### Second-precision (sub-minute) cronlines
86
98
 
87
99
  In addition to the standard 5-parameter cronline format, sidekiq-cron supports scheduling jobs with second-precision using a modified 6-parameter cronline format:
@@ -93,7 +105,7 @@ For example: `"*/30 * * * * *"` would schedule a job to run every 30 seconds.
93
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:
94
106
 
95
107
  ```ruby
96
- Sidekiq.options[:average_scheduled_poll_interval] = 10
108
+ Sidekiq[:cron_poll_interval] = 10
97
109
  ```
98
110
 
99
111
  The default value at time of writing is 30 seconds. See [under the hood](#under-the-hood) for more details.
@@ -226,21 +238,19 @@ second_job:
226
238
  hard: "stuff"
227
239
  ```
228
240
 
229
- ```ruby
230
- # config/initializers/sidekiq.rb
231
- schedule_file = "config/schedule.yml"
232
-
233
- if File.exist?(schedule_file) && Sidekiq.server?
234
- Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
235
- end
236
- ```
241
+ There are multiple ways to load the jobs from a YAML file
237
242
 
238
- From version 3.x it is better not to use separate initializer of schedule instead add `config.on(:startup)` to your Sidekiq configuration:
243
+ 1. The gem will automatically load the jobs mentioned in `config/schedule.yml` file.
244
+ 2. When you want to load jobs from a different filename, mention the filename in sidekiq configuration,
245
+ i.e. `cron_schedule_file: "config/users_schedule.yml"`
246
+ 3. Load the file manually as follows
239
247
 
240
248
  ```ruby
249
+ # config/initializers/sidekiq.rb
250
+
241
251
  Sidekiq.configure_server do |config|
242
252
  config.on(:startup) do
243
- schedule_file = "config/schedule.yml"
253
+ schedule_file = "config/users_schedule.yml"
244
254
 
245
255
  if File.exist?(schedule_file)
246
256
  Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
@@ -249,8 +259,6 @@ Sidekiq.configure_server do |config|
249
259
  end
250
260
  ```
251
261
 
252
- Or you can use for loading jobs from yml file [sidekiq-cron-tasks](https://github.com/coverhound/sidekiq-cron-tasks) which will add rake task `bundle exec rake sidekiq_cron:load` to your rails application.
253
-
254
262
  ### Finding jobs
255
263
 
256
264
  ```ruby
@@ -313,32 +321,7 @@ add `require 'sidekiq/cron/web'` after `require 'sidekiq/web'`.
313
321
 
314
322
  With this, you will get:
315
323
 
316
- ![Web UI](examples/web-cron-ui.png)
317
-
318
- ### Forking Processes or problem with `NotImplementedError`
319
-
320
- If you're using a forking web server like Unicorn you may run into an issue where the Redis connection is used
321
- before the process forks, causing the following exception to occur:
322
-
323
- ```
324
- Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
325
- ```
326
-
327
- To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
328
-
329
- ```ruby
330
- Sidekiq.configure_server do |config|
331
- config.on(:startup) do
332
- schedule_file = "config/schedule.yml"
333
-
334
- if File.exist?(schedule_file)
335
- Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
336
- end
337
- end
338
- end
339
- ```
340
-
341
- **NOTE** This API is only available in Sidekiq 3.x.
324
+ ![Web UI](examples/web-cron-ui.jpeg)
342
325
 
343
326
  ## Under the hood
344
327
 
@@ -349,11 +332,13 @@ Sidekiq-Cron adds itself into this start procedure and starts another thread wit
349
332
  Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can change it by setting:
350
333
 
351
334
  ```ruby
352
- Sidekiq.options[:average_scheduled_poll_interval] = 10
335
+ Sidekiq[:cron_poll_interval] = 10
353
336
  ```
354
337
 
355
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.
356
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
+
357
342
  ## Contributing
358
343
 
359
344
  **Thanks to all [contributors](https://github.com/ondrejbartas/sidekiq-cron/graphs/contributors), you’re awesome and this wouldn’t be possible without you!**
@@ -364,6 +349,7 @@ Sidekiq-Cron is safe to use with multiple Sidekiq processes or nodes. It uses a
364
349
  * Start a feature/bugfix branch.
365
350
  * Commit and push until you are happy with your contribution.
366
351
  * Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
352
+ * Open a pull request!
367
353
 
368
354
  ### Testing
369
355