resque-scheduler 4.3.1 → 4.10.2

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
- SHA1:
3
- metadata.gz: 52d400f5dbdd7e1d642466e7999f6ec7f6805355
4
- data.tar.gz: 7caa30cc7095a5451f915a981b64cd0dda7149e5
2
+ SHA256:
3
+ metadata.gz: 6cf8e385c64ab6efafcc8f3a499ec2dc8d7be736604e7d4578dd356f1c19d6e9
4
+ data.tar.gz: a564652590bf3c5dc85695cbbb57fb4ca85873de78c94f0580a104ef5d98cf55
5
5
  SHA512:
6
- metadata.gz: 20630b816c225504beb88315ef1df2fa1672e44e05c6386446c53e6b5422ab7b1cf478775f6660e7f880a73771f073746fb0853258a5ad71f450b51e15290ce2
7
- data.tar.gz: 8fa83bedc4ffd9759d5390ad19ce82b8188445df3aa5c46ac2a32dc8a162e66c69c73f4599ad90ea4a3eb2191661fe82ece5aea30bd834d3e9e8495267e84a7b
6
+ metadata.gz: 2ab0cea69751963f68055eae115c349a885439a5b33c1c3046a5abd4fc30b676233964d430fa5aeb3eb7960d9339772d41ca31c575156eb4e6583cc66de7497e
7
+ data.tar.gz: f0a4ab726ea640f9df76bbb824078252fb90de9d40c90220611c71069363025933f4a97200c73c13c7c91ff4f02a8c64c735372bbd2e0510e4e5bd021ec081fb
@@ -0,0 +1,12 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+
9
+ - package-ecosystem: "bundler"
10
+ directory: "/"
11
+ schedule:
12
+ interval: "weekly"
@@ -0,0 +1,4 @@
1
+ # Docs for this file can be found here:
2
+ # https://docs.github.com/en/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository
3
+
4
+ github: ["iloveitaly"]
@@ -0,0 +1,59 @@
1
+ name: "CodeQL"
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, '*-stable' ]
6
+ pull_request:
7
+ # The branches below must be a subset of the branches above
8
+ branches: [ master ]
9
+ schedule:
10
+ - cron: '44 16 * * 6'
11
+
12
+ jobs:
13
+ analyze:
14
+ name: Analyze
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ actions: read
18
+ contents: read
19
+ security-events: write
20
+
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ language: [ 'ruby' ]
25
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
27
+
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v4
31
+
32
+ # Initializes the CodeQL tools for scanning.
33
+ - name: Initialize CodeQL
34
+ uses: github/codeql-action/init@v2
35
+ with:
36
+ languages: ${{ matrix.language }}
37
+ # If you wish to specify custom queries, you can do so here or in a config file.
38
+ # By default, queries listed here will override any specified in a config file.
39
+ # Prefix the list here with "+" to use these queries and those in the config file.
40
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
41
+
42
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
43
+ # If this step fails, then you should remove it and run the build manually (see below)
44
+ - name: Autobuild
45
+ uses: github/codeql-action/autobuild@v2
46
+
47
+ # ℹ️ Command-line programs to run using the OS shell.
48
+ # 📚 https://git.io/JvXDl
49
+
50
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
51
+ # and modify them (or add more) to build your code if your project
52
+ # uses a compiled language
53
+
54
+ #- run: |
55
+ # make bootstrap
56
+ # make release
57
+
58
+ - name: Perform CodeQL Analysis
59
+ uses: github/codeql-action/analyze@v2
@@ -0,0 +1,27 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ rubocop:
11
+ name: Rubocop
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ matrix:
15
+ os: [ubuntu-latest]
16
+ ruby: [
17
+ 2.7
18
+ ]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Ruby linter
27
+ run: bundle exec rubocop
@@ -0,0 +1,81 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ continue-on-error: true
12
+ runs-on: ubuntu-latest
13
+ services:
14
+ redis:
15
+ image: redis
16
+ ports:
17
+ - 6379:6379
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby-version:
22
+ - 2.3
23
+ - 2.4
24
+ - 2.5
25
+ - 2.6
26
+ - 2.7
27
+ - "3.0"
28
+ - 3.1
29
+ - 3.2
30
+ resque-version:
31
+ - "master"
32
+ - "~> 2.4.0"
33
+ - "~> 1.27"
34
+ rufus-scheduler:
35
+ - "3.2"
36
+ - "3.4"
37
+ - "3.5"
38
+ - "3.6"
39
+ redis-version:
40
+ - "~> 4.x"
41
+ - "~> 5.x"
42
+ exclude:
43
+ - ruby-version: head
44
+ rufus-scheduler: 3.2
45
+ - ruby-version: 3.2
46
+ rufus-scheduler: 3.2
47
+
48
+ - ruby-version: 2.3
49
+ resque-version: "~> 1.27"
50
+ rufus-scheduler: 3.4
51
+ - ruby-version: 2.3
52
+ resque-version: "~> 1.27"
53
+ rufus-scheduler: 3.5
54
+ - ruby-version: 2.5
55
+ resque-version: "~> 2.4.0"
56
+ rufus-scheduler: 3.5
57
+ - ruby-version: 2.5
58
+ resque-version: master
59
+ rufus-scheduler: 3.2
60
+
61
+ - ruby-version: 2.3
62
+ redis-version: "~> 5.x"
63
+ - ruby-version: 2.4
64
+ redis-version: "~> 5.x"
65
+
66
+ - resque-version: "~> 1.27"
67
+ redis-version: "~> 5.x"
68
+ env:
69
+ REDIS_VERSION: "${{ matrix.redis-version }}"
70
+ RESQUE: "${{ matrix.resque-version }}"
71
+ RUFUS_SCHEDULER: "${{ matrix.rufus-scheduler }}"
72
+ COVERAGE: 1
73
+
74
+ steps:
75
+ - uses: actions/checkout@v4
76
+ - uses: ruby/setup-ruby@v1
77
+ with:
78
+ ruby-version: "${{ matrix.ruby-version }}"
79
+ bundler-cache: true
80
+ - run: bundle exec rake
81
+ - run: bin/bundle_console_test.sh
data/AUTHORS.md CHANGED
@@ -10,6 +10,7 @@ Resque Scheduler authors
10
10
  - Brian Landau
11
11
  - Brian P O'Rourke
12
12
  - Carlos Antonio da Silva
13
+ - Chris Bisnett
13
14
  - Chris Kampmeier
14
15
  - DJ Hartman
15
16
  - Damon P. Cortesi
@@ -27,18 +28,23 @@ Resque Scheduler authors
27
28
  - Harry Lascelles
28
29
  - Henrik Nyh
29
30
  - Hormoz Kheradmand
31
+ - Ian Davies
32
+ - Irving Reid
30
33
  - James Le Cuirot
31
34
  - Jarkko Mönkkönen
35
+ - Jimmy Chao
32
36
  - John Crepezzi
33
37
  - John Griffin
34
38
  - Jon Larkowski and Les Hill
35
39
  - Jonathan Conley
36
40
  - Jonathan Hyman
37
41
  - Jonathan Owens
42
+ - Jordan Gardner
38
43
  - Joshua Szmajda
39
44
  - Justin Weiss
40
45
  - Les Hill
41
46
  - Luke Rodgers
47
+ - Maksymilian Chwałek
42
48
  - Manuel Meurer
43
49
  - Matt Aimonetti
44
50
  - Matt Simpson
@@ -46,6 +52,7 @@ Resque Scheduler authors
46
52
  - Michael Lovitt
47
53
  - Michael Nikitochkin
48
54
  - Michael Rykov
55
+ - Mike MacDonald
49
56
  - Nickolas Means
50
57
  - Olek Janiszewski
51
58
  - Olivier Brisse
@@ -59,11 +66,13 @@ Resque Scheduler authors
59
66
  - Scott Francis
60
67
  - Sean Stephens
61
68
  - Sebastian Kippe
69
+ - Sharang Dashputre
62
70
  - Spring MC
63
71
  - tbprojects
64
72
  - Tim Liner
65
73
  - Tony Lewis
66
74
  - Tom Crayford
75
+ - Tsu-Shiuan Lin
67
76
  - Vincent Zhu
68
77
  - Vladislav Shub
69
78
  - V Sreekanth
@@ -79,3 +88,5 @@ Resque Scheduler authors
79
88
  - malomalo
80
89
  - sawanoboly
81
90
  - serek
91
+ - iloveitaly
92
+ - treacher
data/CHANGELOG.md CHANGED
@@ -2,7 +2,85 @@
2
2
 
3
3
  **ATTN**: This project uses [semantic versioning](http://semver.org/).
4
4
 
5
- ## [Unreleased]
5
+ ## [4.10.2] - 2023-12-15
6
+ ### Fixed
7
+ * Finish fixing CVE-2022-44303, XSS in delayed_schedules by @PatrickTulskie in #783
8
+
9
+ ## [4.10.1] - 2023-12-15
10
+ ### Fixed
11
+ * Fix json dump crasher with JSON 2.7.0+ by @PatrickTulskie in #781
12
+ * Fix for #761, reflected XSS in delayed_schedules.erb by @PatrickTulskie in #780
13
+
14
+ ## [4.10.0] - 2023-08-20
15
+ ### Added
16
+ * Add logfmt option for logging output (#763)
17
+
18
+ ### Fixed
19
+ * Rubocop Fixes (#771)
20
+
21
+ ## [4.9.0] - 2023-05-31
22
+ ### Changed
23
+ - Adding batching to re-queuing for timestamp by @brennen-stripe in #767
24
+ - Use non-deprecated form of Redis.sadd/srem by @irvingreid in #752
25
+ - Prompt for confirmation on 'Clear Delayed Jobs' by @mishina2228 in #754
26
+ - Address some deprecation warnings in the test suite and with srem/lrem pipelined usage by @PatrickTulskie in #770
27
+
28
+ ### Fixed
29
+ - Update CI matrix and fix tests by @mishina2228 in #766
30
+
31
+ ## [4.8.0] - 2023-27-1
32
+ - Replace deprecated Socket.gethostname with Addrinfo.getaddrinfo to fix deprecation warnings (#753)
33
+
34
+ ## [4.7.0] - 2022-10-6
35
+ ### Fixed
36
+ - Fix tests for redis-rb 5.0 (#757)
37
+ - Use Resque::DataStore#reconnect for redis-rb 5.0 compat (#757)
38
+ - Test suite runs `flushall` to prevent flakiness (#757)
39
+
40
+ ## [4.6.0] - 2022-08-04
41
+ ### Changed
42
+ - Remove support for Ruby < 2.3
43
+ - Configuration to use a set of truthy values to enable boolean settings instead of simply existence
44
+ - Add `delay_or_enqueue_at` for delaying existing jobs or creating a new job(#645)
45
+ - Fix deprecated uses of Redis#pipelined
46
+ - Fix reading configuration from environment for boolean values (#735)
47
+ - Unblock rufus-scheduler lock on lower than 3.7 by fixing scheduler shutdown (#736)
48
+ - Removed testing against jruby (resque doesn't test against jruby)
49
+
50
+ ## [4.5.0] - 2021-09-25
51
+ ### Added
52
+ - Support Ruby 3
53
+ - Add optional argument to `remove_schedule` to control reloading of the schedule
54
+
55
+ ### Fixed
56
+ - Fix XSS vulnerability on the `/delayed/search` page
57
+ - Ensure that jobs are directly created for jobs enqueued at `Time.now`
58
+ - Fix queuing to custom job queues in `enqueue_delayed_selection`
59
+ - Ensure `before_enqueue` and `after_enqueue` callbacks are called in all cases of queuing a job
60
+ - Fix redis error when running resque-scheduler without Redis
61
+
62
+ ### Changed
63
+ - Change CI from Travis to GitHub Actions
64
+ - Only allow rufus-scheduler versions lower than 3.7
65
+ - Update vagrant configuration
66
+
67
+ ## [4.4.0] - 2019-04-11
68
+ ### Added
69
+ - Support Resque 2
70
+ - Support redis-rb 4
71
+ - Support Ruby 2.5
72
+
73
+ ### Fixed
74
+ - Redis timeouts no longer crash the scheduler process
75
+ - Fix race condition when running multiple schedulers
76
+ - Fix setting the `poll_sleep_amount` option
77
+ - Escape class names in resque-web /delayed URLs
78
+
79
+ ### Changed
80
+ - Addressed redis-namespace deprecation warnings
81
+ - Ensure `enqueue_in` args are Numeric, catching a common issue passing `ActiveSupport::Duration`
82
+
83
+ ## [4.3.1] - 2017-11-20
6
84
  ### Changed
7
85
  - Add support and testing for ruby 2.4
8
86
  - Change log format and file name
@@ -11,6 +89,7 @@
11
89
 
12
90
  ### Fixed
13
91
  - Reporting version via `resque-scheduler --version`
92
+ - Class name escaping in `/delayed` view
14
93
 
15
94
  ## [4.3.0] - 2016-06-26
16
95
  ### Added
@@ -407,7 +486,10 @@
407
486
  ### Added
408
487
  - Initial release
409
488
 
410
- [Unreleased]: https://github.com/resque/resque-scheduler/compare/v4.3.0...HEAD
489
+ [Unreleased]: https://github.com/resque/resque-scheduler/compare/v4.5.0...HEAD
490
+ [4.5.0]: https://github.com/resque/resque-scheduler/compare/v4.4.0...v4.5.0
491
+ [4.4.0]: https://github.com/resque/resque-scheduler/compare/v4.3.1...v4.4.0
492
+ [4.3.1]: https://github.com/resque/resque-scheduler/compare/v4.3.0...v4.3.1
411
493
  [4.3.0]: https://github.com/resque/resque-scheduler/compare/v4.2.1...v4.3.0
412
494
  [4.2.1]: https://github.com/resque/resque-scheduler/compare/v4.2.0...v4.2.1
413
495
  [4.2.0]: https://github.com/resque/resque-scheduler/compare/v4.1.0...v4.2.0
data/Gemfile CHANGED
@@ -1,4 +1,29 @@
1
1
  # vim:fileencoding=utf-8
2
2
  source 'https://rubygems.org'
3
3
 
4
+ case resque_version = ENV.fetch('RESQUE', 'master')
5
+ when 'master'
6
+ gem 'resque', git: 'https://github.com/resque/resque'
7
+ else
8
+ gem 'resque', resque_version
9
+ end
10
+
11
+ case rufus_scheduler_version = ENV.fetch('RUFUS_SCHEDULER', '3.6')
12
+ when 'master'
13
+ gem 'rufus-scheduler', git: 'https://github.com/jmettraux/rufus-scheduler'
14
+ else
15
+ gem 'rufus-scheduler', rufus_scheduler_version
16
+ end
17
+
18
+ case redis_version = ENV.fetch('REDIS_VERSION', 'latest')
19
+ when 'master'
20
+ gem 'redis', git: 'https://github.com/redis/redis-rb'
21
+ when 'latest'
22
+ gem 'redis'
23
+ else
24
+ gem 'redis', redis_version
25
+ end
26
+
27
+ gem 'sinatra', '> 2.0'
28
+
4
29
  gemspec
data/README.md CHANGED
@@ -2,10 +2,8 @@ resque-scheduler
2
2
  ================
3
3
 
4
4
 
5
- [![Dependency Status](https://gemnasium.com/badges/github.com/resque/resque-scheduler.svg)](https://gemnasium.com/github.com/resque/resque-scheduler)
6
5
  [![Gem Version](https://badge.fury.io/rb/resque-scheduler.svg)](https://badge.fury.io/rb/resque-scheduler)
7
- [![Build Status](https://travis-ci.org/resque/resque-scheduler.svg?branch=master)](https://travis-ci.org/resque/resque-scheduler)
8
- [![Windows Build Status](https://ci.appveyor.com/api/projects/status/sxvf2086v5j0absb/branch/master?svg=true)](https://ci.appveyor.com/project/resque/resque-scheduler/branch/master)
6
+ [![Ruby specs](https://github.com/resque/resque-scheduler/actions/workflows/ruby.yml/badge.svg)](https://github.com/resque/resque-scheduler/actions)
9
7
  [![Code Climate](https://codeclimate.com/github/resque/resque-scheduler/badges/gpa.svg)](https://codeclimate.com/github/resque/resque-scheduler)
10
8
 
11
9
  ### Description
@@ -13,7 +11,7 @@ resque-scheduler
13
11
  Resque-scheduler is an extension to [Resque](http://github.com/resque/resque)
14
12
  that adds support for queueing items in the future.
15
13
 
16
- Job scheduling is supported in two different way: Recurring (scheduled) and
14
+ Job scheduling is supported in two different ways: Recurring (scheduled) and
17
15
  Delayed.
18
16
 
19
17
  Scheduled jobs are like cron jobs, recurring on a regular basis. Delayed
@@ -141,7 +139,7 @@ requiring `resque` and `resque/scheduler` (default empty).
141
139
  * `RESQUE_SCHEDULER_INTERVAL` - Interval in seconds for checking if a
142
140
  scheduled job must run (coerced with `Kernel#Float()`) (default `5`)
143
141
  * `LOGFILE` - Log file name (default empty, meaning `$stdout`)
144
- * `LOGFORMAT` - Log output format to use (either `'text'` or `'json'`,
142
+ * `LOGFORMAT` - Log output format to use (either `'text'`, `'json'` or `'logfmt'`,
145
143
  default `'text'`)
146
144
  * `PIDFILE` - If non-empty, write process PID to file (default empty)
147
145
  * `QUIET` - Silence most output if non-empty (equivalent to a level of
@@ -160,7 +158,7 @@ following task to wherever tasks are kept, such as
160
158
  ```ruby
161
159
  task 'resque:pool:setup' do
162
160
  Resque::Pool.after_prefork do |job|
163
- Resque.redis.client.reconnect
161
+ Resque.redis.reconnect
164
162
  end
165
163
  end
166
164
  ```
@@ -213,7 +211,7 @@ since the jobs are stored in a redis sorted set (zset). I can't imagine this
213
211
  being an issue for someone since redis is stupidly fast even at log(n), but full
214
212
  disclosure is always best.
215
213
 
216
- #### Removing Delayed jobs
214
+ #### Removing Delayed Jobs
217
215
 
218
216
  If you have the need to cancel a delayed job, you can do like so:
219
217
 
@@ -235,6 +233,17 @@ Resque.remove_delayed_selection { |args| args[0]['account_id'] == current_accoun
235
233
  Resque.remove_delayed_selection { |args| args[0]['user_id'] == current_user.id }
236
234
  ```
237
235
 
236
+ If you need to cancel a delayed job based on some matching arguments AND by which class the job is, but don't wish to specify each argument from when the job was created, you can do like so:
237
+
238
+ ``` ruby
239
+ # after you've enqueued a job like:
240
+ Resque.enqueue_at(5.days.from_now, SendFollowUpEmail, :account_id => current_account.id, :user_id => current_user.id)
241
+ # remove jobs matching just the account and that were of the class SendFollowUpEmail:
242
+ Resque.remove_delayed_selection(SendFollowUpEmail) { |args| args[0]['account_id'] == current_account.id }
243
+ # or remove jobs matching just the user and that were of the class SendFollowUpEmail:
244
+ Resque.remove_delayed_selection(SendFollowUpEmail) { |args| args[0]['user_id'] == current_user.id }
245
+ ```
246
+
238
247
  If you need to enqueue immediately a delayed job based on some matching arguments, but don't wish to specify each argument from when the job was created, you can do like so:
239
248
 
240
249
  ``` ruby
@@ -246,6 +255,49 @@ Resque.enqueue_delayed_selection { |args| args[0]['account_id'] == current_accou
246
255
  Resque.enqueue_delayed_selection { |args| args[0]['user_id'] == current_user.id }
247
256
  ```
248
257
 
258
+ #### Updating Delayed Jobs
259
+
260
+ Previously delayed jobs may be delayed even further into the future like so:
261
+
262
+ ```ruby
263
+ # after you've enqueued a job like:
264
+ Resque.enqueue_at(1.minute.from_now, SendNotifications, :user_id => current_user.id)
265
+ # delay running the job until two minutes from now
266
+ Resque.delay_or_enqueue_at(2.minutes.from_now, SendNotifications, :user_id => current_user.id)
267
+ ```
268
+
269
+ You don't need to worry if a matching job has already been queued, because if no matching jobs are found a new job is created and enqueued as if you had called `enqueue_at`. This means you don't need any special conditionals to know if a job has already been queued. You simply create the job like so:
270
+
271
+ ```ruby
272
+ Resque.delay_or_enqueue_at(1.minute.from_now, SendNotifications, :user_id => current_user.id)
273
+ ```
274
+
275
+ If multiple matching jobs are found, all of the matching jobs will be updated to have the same timestamp even if their original timestamps were not the same.
276
+
277
+ ```ruby
278
+ # enqueue multiple jobs with different delay timestamps
279
+ Resque.enqueue_at(1.minute.from_now, SendNotifications, :user_id => current_user.id)
280
+ Resque.enqueue_at(2.minutes.from_now, SendNotifications, :user_id => current_user.id)
281
+
282
+ # delay running the two jobs until 5 minutes from now
283
+ Resque.delay_or_enqueue_at(5.minutes.from_now, SendNotifications, :user_id => current_user.id)
284
+ ```
285
+
286
+ The most useful case for increasing the delay of an already delayed job is to batch together work based on multiple events. For example, if you wanted to send a notification email to a user when an event triggers but didn't want to send 10 emails if many events happened within a short period, you could use this technique to delay the noficication email until no events have triggered for a period of time. This way you could send 1 email containing the 10 notifications once no events have triggered for 2 minutes. You could implement this like so:
287
+
288
+ ```ruby
289
+ # Send a notification when an event is created.
290
+ # app/models/event.rb
291
+ after_commit on: :create do
292
+ Resque.delay_or_enqueue_in(2.minutes, SendNotifications, :user_id => user.id)
293
+ end
294
+ ```
295
+
296
+ When the first event is created a job will be scheduled to send unsent notifications to the associated user. If another event is created within the 2 minute window, the timer will be reset to 2 minutes. This will continue as long as new events are created for the specific user before the 2 minute timer expires. Once the timer expires and the job is scheduled any new events that are created will schedule a new job and start the process over. By adjusting the window you can tweak the trade-off between sending notification emails quickly after an event happens and sending fewer emails.
297
+
298
+ Read more in the [original PR](https://github.com/resque/resque-scheduler/pull/645)
299
+
300
+
249
301
  ### Scheduled Jobs (Recurring Jobs)
250
302
 
251
303
  Scheduled (or recurring) jobs are logically no different than a standard cron
@@ -295,7 +347,6 @@ If you would like to setup a job that is executed manually you can configure lik
295
347
 
296
348
  ```yaml
297
349
  ImportOrdersManual:
298
- description: 'Import Amazon Orders Manual'
299
350
  custom_job_class: 'AmazonMws::ImportOrdersJob'
300
351
  never: "* * * * *"
301
352
  queue: high
@@ -335,11 +386,43 @@ seconds past the minute).
335
386
  A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler)
336
387
  for handling the heavy lifting of the actual scheduling engine.
337
388
 
389
+ ##### Queue with parameters
390
+
391
+ It's possible to specify parameters, that must be given by the user when they manually queue the job. To enable this feature add `parameters` key to scheduled job definition.
392
+
393
+ ```yaml
394
+ queue_documents_for_indexing:
395
+ cron: "0 0 * * *"
396
+ class: "QueueDocuments"
397
+ queue: high
398
+ args:
399
+ foo: "bar"
400
+ a: "b"
401
+ parameters:
402
+ foo:
403
+ description: "value of foo"
404
+ default: "baz"
405
+
406
+ description: "This job queues all content for indexing in solr"
407
+ ```
408
+
409
+ One can use following options for each parameter:
410
+ * description - tooltip to be shown next to the parameter input
411
+ * default - prefilled value in the parameter input
412
+
413
+ **NOTE**: When sheduling the job, parameters are merged into job args. Assuming the example above and default parametr value, the job will be run with the following args:
414
+
415
+ ```ruby
416
+ {"foo"=>"baz", "a"=>"b"}
417
+ ```
418
+
419
+ **NOTE**: If user leaves the parameter value empty, it'll be sent as empty string.
420
+
338
421
  #### Dynamic schedules
339
422
 
340
423
  Dynamic schedules are programmatically set on a running `resque-scheduler`.
341
- All [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler) options are supported
342
- when setting schedules.
424
+ Most [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler) options are supported
425
+ when setting schedules. Specifically the `overlap` option will not work.
343
426
 
344
427
  Dynamic schedules are not enabled by default. To be able to dynamically set schedules, you
345
428
  must pass the following to `resque-scheduler` initialization (see *Installation* above for a more complete example):
@@ -396,18 +479,17 @@ Resque.set_schedule(name, config)
396
479
 
397
480
  #### Time zones
398
481
 
399
- Note that if you use the cron syntax, this will be interpreted as in the server time zone
400
- rather than the `config.time_zone` specified in Rails.
401
-
482
+ If you use the cron syntax, by default it is interpreted in the server time zone.
402
483
  You can explicitly specify the time zone that rufus-scheduler will use:
403
-
404
484
  ```yaml
405
485
  cron: "30 6 * * 1 Europe/Stockholm"
406
486
  ```
407
487
 
408
- Also note that `config.time_zone` in Rails allows for a shorthand (e.g. "Stockholm")
409
- that rufus-scheduler does not accept. If you write code to set the scheduler time zone
410
- from the `config.time_zone` value, make sure it's the right format, e.g. with:
488
+ ##### Rails
489
+ In Rails, `config.time_zone` will be used to determine the time zone for `resque-scheduler`.
490
+
491
+ Note that `config.time_zone` allows for a shorthand (e.g. "Stockholm")
492
+ that rufus-scheduler does not accept, so make sure it's the right format, e.g. with:
411
493
 
412
494
  ```ruby
413
495
  ActiveSupport::TimeZone.find_tzinfo(Rails.configuration.time_zone).name
@@ -516,7 +598,7 @@ RESQUE_SCHEDULER_MASTER_LOCK_PREFIX=MyApp: rake resque:scheduler
516
598
 
517
599
  ### resque-web Additions
518
600
 
519
- Resque-scheduler also adds to tabs to the resque-web UI. One is for viewing
601
+ Resque-scheduler also adds two tabs to the resque-web UI. One is for viewing
520
602
  (and manually queueing) the schedule and one is for viewing pending jobs in
521
603
  the delayed queue.
522
604
 
@@ -550,11 +632,7 @@ require 'resque/scheduler/server'
550
632
 
551
633
  That should make the scheduler tabs show up in `resque-web`.
552
634
 
553
- #### Changes as of 2.0.0
554
-
555
- As of resque-scheduler 2.0.0, it's no longer necessary to have the resque-web
556
- process aware of the schedule because it reads it from redis. But prior to
557
- 2.0, you'll want to make sure you load the schedule in this file as well.
635
+ You'll want to make sure you load the schedule in this file as well.
558
636
  Something like this:
559
637
 
560
638
  ```ruby
@@ -568,7 +646,7 @@ Now make sure you're passing that file to resque-web like so:
568
646
 
569
647
  ### Running in the background
570
648
 
571
- (Only supported with ruby >= 1.9). There are scenarios where it's helpful for
649
+ There are scenarios where it's helpful for
572
650
  the resque worker to run itself in the background (usually in combination with
573
651
  PIDFILE). Use the BACKGROUND option so that rake will return as soon as the
574
652
  worker is started.
@@ -585,7 +663,7 @@ are toggled by environment variables:
585
663
  - `QUIET` will stop logging anything. Completely silent.
586
664
  - `VERBOSE` opposite of 'QUIET'; will log even debug information
587
665
  - `LOGFILE` specifies the file to write logs to. (default standard output)
588
- - `LOGFORMAT` specifies either "text" or "json" output format
666
+ - `LOGFORMAT` specifies either "text", "json" or "logfmt" output format
589
667
  (default "text")
590
668
 
591
669
  All of these variables are optional and will be given the following default
@@ -634,7 +712,7 @@ that happens on Travis CI and Appveyor:
634
712
  bundle install
635
713
 
636
714
  # Make sure tests are green before you change stuff
637
- bundle exec rake
715
+ bundle exec rubocop && bundle exec rake
638
716
  # Change stuff
639
717
  # Repeat
640
718
  ```
data/Rakefile CHANGED
@@ -1,13 +1,9 @@
1
1
  # vim:fileencoding=utf-8
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rake/testtask'
4
- require 'rubocop/rake_task'
5
4
  require 'yard'
6
5
 
7
- task default: [:rubocop, :test] unless RUBY_PLATFORM =~ /java/
8
- task default: [:test] if RUBY_PLATFORM =~ /java/
9
-
10
- RuboCop::RakeTask.new
6
+ task default: :test
11
7
 
12
8
  Rake::TestTask.new do |t|
13
9
  t.libs << 'test'
@@ -16,6 +12,7 @@ Rake::TestTask.new do |t|
16
12
  o << "--seed #{ENV['SEED']} " if ENV['SEED']
17
13
  o << '--verbose ' if ENV['VERBOSE']
18
14
  end
15
+ t.warning = false
19
16
  end
20
17
 
21
18
  YARD::Rake::YardocTask.new