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 +4 -4
- data/{Changes.md → CHANGELOG.md} +33 -5
- data/README.md +32 -46
- data/lib/sidekiq/cron/job.rb +108 -99
- data/lib/sidekiq/cron/launcher.rb +15 -13
- data/lib/sidekiq/cron/locales/it.yml +23 -0
- data/lib/sidekiq/cron/locales/pt.yml +22 -0
- data/lib/sidekiq/cron/poller.rb +16 -8
- data/lib/sidekiq/cron/schedule_loader.rb +22 -0
- data/lib/sidekiq/cron/support.rb +0 -1
- data/lib/sidekiq/cron/version.rb +1 -1
- data/lib/sidekiq/cron/views/cron.erb +1 -1
- data/lib/sidekiq/cron/web_extension.rb +6 -9
- data/lib/sidekiq/cron.rb +1 -0
- data/lib/sidekiq/options.rb +18 -0
- data/sidekiq-cron.gemspec +13 -15
- data/test/integration/performance_test.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/unit/fixtures/schedule_array.yml +13 -0
- data/test/unit/fixtures/schedule_hash.yml +12 -0
- data/test/unit/fixtures/schedule_string.yml +1 -0
- data/test/unit/job_test.rb +125 -21
- data/test/unit/launcher_test.rb +33 -0
- data/test/unit/poller_test.rb +6 -6
- data/test/unit/schedule_loader_test.rb +45 -0
- data/test/unit/web_extension_test.rb +2 -2
- metadata +37 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df934577b0740b3e977ffd0e361f6333de6958921659d78bf4c4e4a0015aad9
|
4
|
+
data.tar.gz: 6ae3317c56ff984bf0b651df9117121b4cf67cf36d715eee56a7521f47fe0770
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8948ce194538c052c1761b921a4df485bc99ab5ce9b2e4c12b576d90e10bb6bb1691d7fe111d8ecc6b54e3324d53b8c5c45c0be561d58c4adb4414f08db576b8
|
7
|
+
data.tar.gz: 2fcccab9c996fe7a6c79c0090875dd81fca30ba6de130af3cf300d1d745e0212e056afe4ea05a8912191703cddf47800f5e3ea6092e1e751091ecf4a3baffc15
|
data/{Changes.md → CHANGELOG.md}
RENAMED
@@ -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
|
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
|
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](
|
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"
|
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
|
67
|
-
'queue_name_prefix' => 'prefix', #
|
68
|
-
'queue_name_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
|
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
|
-
|
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
|
-
|
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/
|
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.
|
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
|
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
|
|