sidekiq-cron 1.5.0 → 1.7.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: 30fae647f59944364617d071e3e37b7d2d4b8b8153d4cee4aa05a1cfbfe387e5
4
- data.tar.gz: c7c6ef11245172570823464e660ce427657ec676e2593b75705deddfed744d5d
3
+ metadata.gz: d16f511a8148eadb1246263f53b596b643f9a653e0fb7877e8eaa6e0d0f2f57c
4
+ data.tar.gz: 874babda0f4da8f7928b69a226b967d79d59eacc79c101d0e087f064d31e6423
5
5
  SHA512:
6
- metadata.gz: 161fe2edda57f601085515076a2a6375bcf97018124af3993de70fe16624d7b0fcaeefb1cfeac4d0ae5dbc6292ee299faf67a443b7fd8f8e044ed58f118e98f3
7
- data.tar.gz: b16fb8618c719b9e9c0d39df2e1b6eb6bbaefe8ce80d1d27fea75f84c9ffc8c3fc9df8860b3409bd3d65eb2b01b3c25917a961ea9911609ed8cff5e6912e2f70
6
+ metadata.gz: c23cfaf18069f8e85b777807e2ceaab25d7a0d58983541044e84791e5f484998d00b5042f1f25222f050f7900d182c371227c03270cd66243c440d02cf98065b
7
+ data.tar.gz: 4e809ad13f7cde7f02a3e3ea44c6500e3e430c95e8ae12136b7625bc8ab7a452748e3769adbbef619d033a4346800693b329c40c1f4836594e8c242e4089737f
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 1.7.0
6
+
7
+ - Enable to use cron notation in natural language (ie `every 30 minutes`) (https://github.com/ondrejbartas/sidekiq-cron/pull/312)
8
+ - Fix `date_as_argument` feature to add timestamp argument at every cron job execution (https://github.com/ondrejbartas/sidekiq-cron/pull/329)
9
+ - Introduce `Sidekiq::Options` to centralize reading/writing options from different Sidekiq versions (https://github.com/ondrejbartas/sidekiq-cron/pull/341)
10
+ - Make auto schedule loading compatible with Array format (https://github.com/ondrejbartas/sidekiq-cron/pull/345)
11
+
12
+ ## 1.6.0
13
+
14
+ - Adds support for auto-loading the `config/schedule.yml` file (https://github.com/ondrejbartas/sidekiq-cron/pull/337)
15
+ - Fix `Sidekiq.options` deprecation warning (https://github.com/ondrejbartas/sidekiq-cron/pull/338)
16
+
17
+ ## 1.5.1
18
+
19
+ - Fixes an issue that prevented the gem to work in previous Sidekiq versions (https://github.com/ondrejbartas/sidekiq-cron/pull/335)
20
+
5
21
  ## 1.5.0
6
22
 
7
23
  - Integrate Sidekiq v6.5 breaking changes (https://github.com/ondrejbartas/sidekiq-cron/pull/331)
@@ -21,7 +37,6 @@ All notable changes to this project will be documented in this file.
21
37
 
22
38
  - Add confirmation dialog when enquing jobs from UI
23
39
  - Start to support Sidekiq `average_scheduled_poll_interval` option (replaced `poll_interval`)
24
- - Enable to use latest fugit to parse cron notation alowing use of natural language (ie `"every 30 minutes"`)
25
40
  - Fix deprecation warning for Redis 4.6.x
26
41
  - Fix different response from Redis#exists in different Redis versions
27
42
  - All PRs:
@@ -43,7 +58,7 @@ All notable changes to this project will be documented in this file.
43
58
 
44
59
  - Updated readme
45
60
  - Fix unit tests - changed argument error when getting invalid cron format
46
- - When fallbacking old job enqueued time use `Time.parse` without format (so ruby can decide best method to parse it)
61
+ - When fallbacking old job enqueued time use `Time.parse` without format (so Ruby can decide best method to parse it)
47
62
  - Add option `date_as_argument` which will add to your job arguments on last place `Time.now.to_f` when it was eneuqued
48
63
  - Add option `description` which will allow you to add notes to your jobs so in web view you can see it
49
64
  - Fixed translations
@@ -67,8 +82,8 @@ All notable changes to this project will be documented in this file.
67
82
  - Fix poller to enqueu all jobs in poll start time
68
83
  - Add performance test for enqueue of jobs (10 000 jobs in less than 19s)
69
84
  - Fix problem with default queue
70
- - Remove redis-namespace from dependencies
71
- - Update ruby versions in travis
85
+ - Remove `redis-namespace` from dependencies
86
+ - Update Ruby versions in Travis
72
87
 
73
88
  ## 0.5.0
74
89
 
@@ -80,7 +95,7 @@ All notable changes to this project will be documented in this file.
80
95
  - Add Russian locale
81
96
  - User Rack.env in tests
82
97
  - Faster enqueue of jobs
83
- - Permit to use ActiveJob::Base.queue_name_delimiter
98
+ - Permit to use `ActiveJob::Base.queue_name_delimiter`
84
99
  - Fix problem with multiple times enqueue #84
85
100
  - Fix problem with enqueue of unknown class
86
101
 
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
 
@@ -64,10 +64,10 @@ gem "sidekiq-cron"
64
64
  'queue' => 'name of queue',
65
65
  'args' => '[Array or Hash] of arguments which will be passed to perform method',
66
66
  'date_as_argument' => true, # add the time of execution as last argument of the perform method
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.'
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'
71
71
  'status' => 'disabled' # default: enabled
72
72
  }
73
73
  ```
@@ -83,6 +83,17 @@ If using Rails, this is evaluated against the timezone configured in Rails, othe
83
83
  If you want to have your jobs enqueued based on a different time zone you can specify a timezone in the cronline,
84
84
  like this `'0 22 * * 1-5 America/Chicago'`.
85
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
+
86
97
  #### Second-precision (sub-minute) cronlines
87
98
 
88
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:
@@ -94,7 +105,7 @@ For example: `"*/30 * * * * *"` would schedule a job to run every 30 seconds.
94
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:
95
106
 
96
107
  ```ruby
97
- Sidekiq.options[:average_scheduled_poll_interval] = 10
108
+ Sidekiq[:average_scheduled_poll_interval] = 10
98
109
  ```
99
110
 
100
111
  The default value at time of writing is 30 seconds. See [under the hood](#under-the-hood) for more details.
@@ -227,21 +238,19 @@ second_job:
227
238
  hard: "stuff"
228
239
  ```
229
240
 
230
- ```ruby
231
- # config/initializers/sidekiq.rb
232
- schedule_file = "config/schedule.yml"
233
-
234
- if File.exist?(schedule_file) && Sidekiq.server?
235
- Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
236
- end
237
- ```
241
+ There are multiple ways to load the jobs from a YAML file
238
242
 
239
- 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
240
247
 
241
248
  ```ruby
249
+ # config/initializers/sidekiq.rb
250
+
242
251
  Sidekiq.configure_server do |config|
243
252
  config.on(:startup) do
244
- schedule_file = "config/schedule.yml"
253
+ schedule_file = "config/users_schedule.yml"
245
254
 
246
255
  if File.exist?(schedule_file)
247
256
  Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
@@ -250,8 +259,6 @@ Sidekiq.configure_server do |config|
250
259
  end
251
260
  ```
252
261
 
253
- 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.
254
-
255
262
  ### Finding jobs
256
263
 
257
264
  ```ruby
@@ -314,32 +321,7 @@ add `require 'sidekiq/cron/web'` after `require 'sidekiq/web'`.
314
321
 
315
322
  With this, you will get:
316
323
 
317
- ![Web UI](examples/web-cron-ui.png)
318
-
319
- ### Forking Processes or problem with `NotImplementedError`
320
-
321
- If you're using a forking web server like Unicorn you may run into an issue where the Redis connection is used
322
- before the process forks, causing the following exception to occur:
323
-
324
- ```
325
- Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
326
- ```
327
-
328
- To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
329
-
330
- ```ruby
331
- Sidekiq.configure_server do |config|
332
- config.on(:startup) do
333
- schedule_file = "config/schedule.yml"
334
-
335
- if File.exist?(schedule_file)
336
- Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
337
- end
338
- end
339
- end
340
- ```
341
-
342
- **NOTE** This API is only available in Sidekiq 3.x.
324
+ ![Web UI](examples/web-cron-ui.jpeg)
343
325
 
344
326
  ## Under the hood
345
327
 
@@ -350,7 +332,7 @@ Sidekiq-Cron adds itself into this start procedure and starts another thread wit
350
332
  Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can change it by setting:
351
333
 
352
334
  ```ruby
353
- Sidekiq.options[:average_scheduled_poll_interval] = 10
335
+ Sidekiq[:average_scheduled_poll_interval] = 10
354
336
  ```
355
337
 
356
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.