good_job 2.11.2 → 2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +12 -17
- data/lib/good_job/cli.rb +5 -5
- data/lib/good_job/cron_entry.rb +11 -1
- data/lib/good_job/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c804e28bcaae78b4af5a654da6cacd9fba979159fb57cbbcfb4bcb348b947fa
|
4
|
+
data.tar.gz: cbd920c5050bcf5da2e328a3aa5c3bb638b5a077a3f67e6dbbf76202a38ec723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cef26c910377e43dc66facdb2ccbde95ace6b38c8a1a6672100496919573f3ce07f0e59cd68ee22f195f72590313ff66757086123be3beee07f0801ecf258bf8
|
7
|
+
data.tar.gz: ee5553f45df7ea0bb4eb7abb870a879556292a7b25247db8d40700347f639b98bfdc758105588a8059a07ac4d7a5d7ccc6e0ba5543daf5cae4e035431f021174
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v2.11.3](https://github.com/bensheldon/good_job/tree/v2.11.3) (2022-03-30)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.11.2...v2.11.3)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Add explicit `kwargs:` key to cron configuration [\#548](https://github.com/bensheldon/good_job/pull/548) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- ArgumentError: wrong number of arguments \(given 1, expected 0; required keyword: schedule\) - cron [\#546](https://github.com/bensheldon/good_job/issues/546)
|
14
|
+
- How to run clean up preserved jobs in cron? [\#541](https://github.com/bensheldon/good_job/issues/541)
|
15
|
+
- Erroring with "Too many open files" when good\_job tries reconnecting to database [\#530](https://github.com/bensheldon/good_job/issues/530)
|
16
|
+
- Can't cast Array [\#529](https://github.com/bensheldon/good_job/issues/529)
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- Use bundle add instead [\#542](https://github.com/bensheldon/good_job/pull/542) ([glaucocustodio](https://github.com/glaucocustodio))
|
21
|
+
- Update Readme to better explain queues, pools, threads, and database connections; update CLI to frontload queue option [\#539](https://github.com/bensheldon/good_job/pull/539) ([bensheldon](https://github.com/bensheldon))
|
22
|
+
|
3
23
|
## [v2.11.2](https://github.com/bensheldon/good_job/tree/v2.11.2) (2022-03-03)
|
4
24
|
|
5
25
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.11.1...v2.11.2)
|
data/README.md
CHANGED
@@ -65,16 +65,10 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
65
65
|
|
66
66
|
## Set up
|
67
67
|
|
68
|
-
1. Add `good_job` to your application's Gemfile:
|
68
|
+
1. Add `good_job` to your application's Gemfile and install the gem:
|
69
69
|
|
70
|
-
```
|
71
|
-
|
72
|
-
```
|
73
|
-
|
74
|
-
1. Install the gem:
|
75
|
-
|
76
|
-
```bash
|
77
|
-
bundle install
|
70
|
+
```sh
|
71
|
+
bundle add good_job
|
78
72
|
```
|
79
73
|
|
80
74
|
1. Run the GoodJob install generator. This will generate a database migration to create a table for GoodJob's job records:
|
@@ -165,8 +159,8 @@ Usage:
|
|
165
159
|
good_job start
|
166
160
|
|
167
161
|
Options:
|
168
|
-
[--
|
169
|
-
[--
|
162
|
+
[--queues=QUEUE_LIST] # Queues or pools to work from. (env var: GOOD_JOB_QUEUES, default: *)
|
163
|
+
[--max-threads=COUNT] # Default number of threads per pool to use for working jobs. (env var: GOOD_JOB_MAX_THREADS, default: 5)
|
170
164
|
[--poll-interval=SECONDS] # Interval between polls for available jobs in seconds (env var: GOOD_JOB_POLL_INTERVAL, default: 1)
|
171
165
|
[--max-cache=COUNT] # Maximum number of scheduled jobs to cache in memory (env var: GOOD_JOB_MAX_CACHE, default: 10000)
|
172
166
|
[--shutdown-timeout=SECONDS] # Number of seconds to wait for jobs to finish when shutting down before stopping the thread. (env var: GOOD_JOB_SHUTDOWN_TIMEOUT, default: -1 (forever))
|
@@ -230,12 +224,12 @@ Rails.application.configure do
|
|
230
224
|
config.good_job.retry_on_unhandled_error = false
|
231
225
|
config.good_job.on_thread_error = -> (exception) { Raven.capture_exception(exception) }
|
232
226
|
config.good_job.execution_mode = :async
|
227
|
+
config.good_job.queues = '*'
|
233
228
|
config.good_job.max_threads = 5
|
234
229
|
config.good_job.poll_interval = 30 # seconds
|
235
230
|
config.good_job.shutdown_timeout = 25 # seconds
|
236
231
|
config.good_job.enable_cron = true
|
237
232
|
config.good_job.cron = { example: { cron: '0 * * * *', class: 'ExampleJob' } }
|
238
|
-
config.good_job.queues = '*'
|
239
233
|
|
240
234
|
# ...or all at once.
|
241
235
|
config.good_job = {
|
@@ -243,6 +237,7 @@ Rails.application.configure do
|
|
243
237
|
retry_on_unhandled_error: false,
|
244
238
|
on_thread_error: -> (exception) { Raven.capture_exception(exception) },
|
245
239
|
execution_mode: :async,
|
240
|
+
queues: '*',
|
246
241
|
max_threads: 5,
|
247
242
|
poll_interval: 30,
|
248
243
|
shutdown_timeout: 25,
|
@@ -253,7 +248,6 @@ Rails.application.configure do
|
|
253
248
|
class: 'ExampleJob'
|
254
249
|
},
|
255
250
|
},
|
256
|
-
queues: '*',
|
257
251
|
}
|
258
252
|
end
|
259
253
|
```
|
@@ -265,8 +259,8 @@ Available configuration options are:
|
|
265
259
|
- `:external` causes the adapter to enqueue jobs, but not execute them. When using this option (the default for production environments), you’ll need to use the command-line tool to actually execute your jobs.
|
266
260
|
- `:async` (or `:async_server`) executes jobs in separate threads within the Rails web server process (`bundle exec rails server`). It can be more economical for small workloads because you don’t need a separate machine or environment for running your jobs, but if your web server is under heavy load or your jobs require a lot of resources, you should choose `:external` instead. When not in the Rails web server, jobs will execute in `:external` mode to ensure jobs are not executed within `rails console`, `rails db:migrate`, `rails assets:prepare`, etc.
|
267
261
|
- `:async_all` executes jobs in separate threads in _any_ Rails process.
|
268
|
-
- `
|
269
|
-
- `
|
262
|
+
- `queues` (string) sets queues or pools to execute jobs. You can also set this with the environment variable `GOOD_JOB_QUEUES`.
|
263
|
+
- `max_threads` (integer) sets the default number of threads per pool to use for working jobs. You can also set this with the environment variable `GOOD_JOB_MAX_THREADS`.
|
270
264
|
- `poll_interval` (integer) sets the number of seconds between polls for jobs when `execution_mode` is set to `:async`. You can also set this with the environment variable `GOOD_JOB_POLL_INTERVAL`. A poll interval of `-1` disables polling completely.
|
271
265
|
- `max_cache` (integer) sets the maximum number of scheduled jobs that will be stored in memory to reduce execution latency when also polling for scheduled jobs. Caching 10,000 scheduled jobs uses approximately 20MB of memory. You can also set this with the environment variable `GOOD_JOB_MAX_CACHE`.
|
272
266
|
- `shutdown_timeout` (float) number of seconds to wait for jobs to finish when shutting down before stopping the thread. Defaults to forever: `-1`. You can also set this with the environment variable `GOOD_JOB_SHUTDOWN_TIMEOUT`.
|
@@ -442,7 +436,8 @@ config.good_job.cron = {
|
|
442
436
|
frequent_task: { # each recurring job must have a unique key
|
443
437
|
cron: "*/15 * * * *", # cron-style scheduling format by fugit gem
|
444
438
|
class: "ExampleJob", # reference the Job class with a string
|
445
|
-
args: [42,
|
439
|
+
args: [42, "life"], # positional arguments to pass; can also be a proc e.g. `-> { [Time.now] }`
|
440
|
+
kwargs: { name: "Alice" }, # keyword arguments to pass; can also be a proc e.g. `-> { { name: NAMES.sample } }`
|
446
441
|
set: { priority: -10 }, # additional ActiveJob properties; can also be a lambda/proc e.g. `-> { { priority: [1,2].sample } }`
|
447
442
|
description: "Something helpful", # optional description that appears in Dashboard (coming soon!)
|
448
443
|
},
|
@@ -679,7 +674,7 @@ Each GoodJob execution thread requires its own database connection that is autom
|
|
679
674
|
|
680
675
|
```yaml
|
681
676
|
# config/database.yml
|
682
|
-
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5).to_i + (ENV.fetch("GOOD_JOB_MAX_THREADS",
|
677
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5).to_i + 3 + (ENV.fetch("GOOD_JOB_MAX_THREADS", 5).to_i %>
|
683
678
|
```
|
684
679
|
|
685
680
|
To calculate the total number of the database connections you'll need:
|
data/lib/good_job/cli.rb
CHANGED
@@ -50,14 +50,14 @@ module GoodJob
|
|
50
50
|
separate isolated execution pools with semicolons and threads with colons.
|
51
51
|
|
52
52
|
DESCRIPTION
|
53
|
-
method_option :max_threads,
|
54
|
-
type: :numeric,
|
55
|
-
banner: 'COUNT',
|
56
|
-
desc: "Maximum number of threads to use for working jobs. (env var: GOOD_JOB_MAX_THREADS, default: 5)"
|
57
53
|
method_option :queues,
|
58
54
|
type: :string,
|
59
55
|
banner: "QUEUE_LIST",
|
60
|
-
desc: "Queues to work from. (env var: GOOD_JOB_QUEUES, default: *)"
|
56
|
+
desc: "Queues or queue pools to work from. (env var: GOOD_JOB_QUEUES, default: *)"
|
57
|
+
method_option :max_threads,
|
58
|
+
type: :numeric,
|
59
|
+
banner: 'COUNT',
|
60
|
+
desc: "Default number of threads per pool to use for working jobs. (env var: GOOD_JOB_MAX_THREADS, default: 5)"
|
61
61
|
method_option :poll_interval,
|
62
62
|
type: :numeric,
|
63
63
|
banner: 'SECONDS',
|
data/lib/good_job/cron_entry.rb
CHANGED
@@ -52,6 +52,10 @@ module GoodJob # :nodoc:
|
|
52
52
|
params[:args]
|
53
53
|
end
|
54
54
|
|
55
|
+
def kwargs
|
56
|
+
params[:kwargs]
|
57
|
+
end
|
58
|
+
|
55
59
|
def description
|
56
60
|
params[:description]
|
57
61
|
end
|
@@ -87,7 +91,8 @@ module GoodJob # :nodoc:
|
|
87
91
|
current_thread.cron_key = key
|
88
92
|
current_thread.cron_at = cron_at
|
89
93
|
|
90
|
-
job_class.constantize.set(set_value)
|
94
|
+
configured_job = job_class.constantize.set(set_value)
|
95
|
+
kwargs_value.present? ? configured_job.perform_later(*args_value, **kwargs_value) : configured_job.perform_later(*args_value)
|
91
96
|
end
|
92
97
|
rescue ActiveRecord::RecordNotUnique
|
93
98
|
false
|
@@ -124,6 +129,11 @@ module GoodJob # :nodoc:
|
|
124
129
|
value.respond_to?(:call) ? value.call : value
|
125
130
|
end
|
126
131
|
|
132
|
+
def kwargs_value
|
133
|
+
value = kwargs || nil
|
134
|
+
value.respond_to?(:call) ? value.call : value
|
135
|
+
end
|
136
|
+
|
127
137
|
def display_property(value)
|
128
138
|
case value
|
129
139
|
when NilClass
|
data/lib/good_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: good_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|