good_job 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -0
- data/README.md +51 -20
- data/engine/app/assets/vendor/rails_ujs.js +747 -0
- data/engine/app/controllers/good_job/assets_controller.rb +4 -0
- data/engine/app/controllers/good_job/base_controller.rb +8 -0
- data/engine/app/controllers/good_job/cron_entries_controller.rb +19 -0
- data/engine/app/controllers/good_job/jobs_controller.rb +36 -0
- data/engine/app/filters/good_job/base_filter.rb +12 -7
- data/engine/app/filters/good_job/executions_filter.rb +1 -1
- data/engine/app/filters/good_job/jobs_filter.rb +4 -2
- data/engine/app/views/good_job/cron_entries/index.html.erb +51 -0
- data/engine/app/views/good_job/cron_entries/show.html.erb +4 -0
- data/engine/app/views/good_job/{shared/_executions_table.erb → executions/_table.erb} +1 -1
- data/engine/app/views/good_job/executions/index.html.erb +1 -1
- data/engine/app/views/good_job/{shared/_jobs_table.erb → jobs/_table.erb} +17 -5
- data/engine/app/views/good_job/jobs/index.html.erb +14 -1
- data/engine/app/views/good_job/jobs/show.html.erb +2 -2
- data/engine/app/views/good_job/shared/_filter.erb +9 -10
- data/engine/app/views/good_job/shared/icons/_arrow_clockwise.html.erb +5 -0
- data/engine/app/views/good_job/shared/icons/_play.html.erb +4 -0
- data/engine/app/views/good_job/shared/icons/_skip_forward.html.erb +4 -0
- data/engine/app/views/good_job/shared/icons/_stop.html.erb +4 -0
- data/engine/app/views/layouts/good_job/base.html.erb +3 -1
- data/engine/config/routes.rb +15 -2
- data/lib/generators/good_job/install_generator.rb +6 -0
- data/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb +3 -1
- data/lib/generators/good_job/templates/update/migrations/{01_create_good_jobs.rb → 01_create_good_jobs.rb.erb} +1 -1
- data/lib/generators/good_job/templates/update/migrations/02_add_cron_at_to_good_jobs.rb.erb +14 -0
- data/lib/generators/good_job/templates/update/migrations/03_add_cron_key_cron_at_index_to_good_jobs.rb.erb +20 -0
- data/lib/generators/good_job/update_generator.rb +6 -0
- data/lib/good_job/active_job_extensions/concurrency.rb +3 -4
- data/lib/good_job/active_job_job.rb +245 -0
- data/lib/good_job/adapter.rb +4 -2
- data/lib/good_job/cli.rb +3 -1
- data/lib/good_job/configuration.rb +5 -1
- data/lib/good_job/cron_entry.rb +138 -0
- data/lib/good_job/cron_manager.rb +17 -31
- data/lib/good_job/current_thread.rb +38 -5
- data/lib/good_job/execution.rb +50 -25
- data/lib/good_job/lockable.rb +1 -1
- data/lib/good_job/log_subscriber.rb +3 -3
- data/lib/good_job/scheduler.rb +1 -0
- data/lib/good_job/version.rb +1 -1
- metadata +21 -12
- data/engine/app/controllers/good_job/cron_schedules_controller.rb +0 -9
- data/engine/app/models/good_job/active_job_job.rb +0 -127
- data/engine/app/views/good_job/cron_schedules/index.html.erb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a5722e06395e2296ea815b0b5780b9c6e24f368168e9951de4bd774c50e154c
|
4
|
+
data.tar.gz: 5a0c5fdff3baf14dcd6153ecb3103c8b0aea1d73f3ff65018c7f32960704b75f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 198cb74f7235861982090467767970685dc2a326b6086030e03697d55c865edb12f28f0e915ef1c1f0d6438495572023d0d59af23071f16ea9262d5c91e53f9c
|
7
|
+
data.tar.gz: ea2546a48fdfbed66d016cf52beaed68d5f487a329d37b7c7152eec0b318eb4597887945180a4232a3462588f8ec6ede5558587f29cfefb33406bb5c6465263e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,94 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v2.6.0](https://github.com/bensheldon/good_job/tree/v2.6.0) (2021-10-30)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.5.0...v2.6.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Allow for cron schedules to be expressed using fugit natural language parsing [\#441](https://github.com/bensheldon/good_job/pull/441) ([jgrau](https://github.com/jgrau))
|
10
|
+
- Add Rails UJS javascript to Dashboard along with confirmations [\#437](https://github.com/bensheldon/good_job/pull/437) ([bensheldon](https://github.com/bensheldon))
|
11
|
+
- Reorganize Cron dashboard screen; add jobs drill-drown and enqueue-now action [\#436](https://github.com/bensheldon/good_job/pull/436) ([bensheldon](https://github.com/bensheldon))
|
12
|
+
|
13
|
+
**Closed issues:**
|
14
|
+
|
15
|
+
- Ability to express cron schedule using fugit natural language parser [\#439](https://github.com/bensheldon/good_job/issues/439)
|
16
|
+
- Best way to ensure ordering of a queue. [\#402](https://github.com/bensheldon/good_job/issues/402)
|
17
|
+
- ActiveJob concurrency raises FrozenError [\#386](https://github.com/bensheldon/good_job/issues/386)
|
18
|
+
|
19
|
+
## [v2.5.0](https://github.com/bensheldon/good_job/tree/v2.5.0) (2021-10-25)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.4.2...v2.5.0)
|
22
|
+
|
23
|
+
**Implemented enhancements:**
|
24
|
+
|
25
|
+
- Add Reschedule, Discard, Retry Job buttons to Dashboard [\#425](https://github.com/bensheldon/good_job/pull/425) ([bensheldon](https://github.com/bensheldon))
|
26
|
+
- Use unique index on \[cron\_key, cron\_at\] columns to prevent duplicate cron jobs from being enqueued [\#423](https://github.com/bensheldon/good_job/pull/423) ([bensheldon](https://github.com/bensheldon))
|
27
|
+
|
28
|
+
**Fixed bugs:**
|
29
|
+
|
30
|
+
- Dashboard fix preservation of `limit` and `queue_name` filter params; add pager to jobs [\#434](https://github.com/bensheldon/good_job/pull/434) ([bensheldon](https://github.com/bensheldon))
|
31
|
+
|
32
|
+
**Closed issues:**
|
33
|
+
|
34
|
+
- PgLock state inspection is not isolated to current database [\#431](https://github.com/bensheldon/good_job/issues/431)
|
35
|
+
- Race condition with concurency control [\#378](https://github.com/bensheldon/good_job/issues/378)
|
36
|
+
|
37
|
+
**Merged pull requests:**
|
38
|
+
|
39
|
+
- Add Readme note about race conditions in Concurrency's `enqueue\_limit` and `perform\_limit [\#433](https://github.com/bensheldon/good_job/pull/433) ([bensheldon](https://github.com/bensheldon))
|
40
|
+
- Test harness should only force-unlock db connections for the current database [\#430](https://github.com/bensheldon/good_job/pull/430) ([bensheldon](https://github.com/bensheldon))
|
41
|
+
|
42
|
+
## [v2.4.2](https://github.com/bensheldon/good_job/tree/v2.4.2) (2021-10-19)
|
43
|
+
|
44
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.4.1...v2.4.2)
|
45
|
+
|
46
|
+
**Implemented enhancements:**
|
47
|
+
|
48
|
+
- Add migration version to install/update generator templates [\#426](https://github.com/bensheldon/good_job/pull/426) ([bensheldon](https://github.com/bensheldon))
|
49
|
+
|
50
|
+
**Fixed bugs:**
|
51
|
+
|
52
|
+
- Explicitly unscope queries within block yielded to Lockable.within\_advisory\_lock [\#429](https://github.com/bensheldon/good_job/pull/429) ([bensheldon](https://github.com/bensheldon))
|
53
|
+
- Fix Demo CleanupJob args [\#427](https://github.com/bensheldon/good_job/pull/427) ([bensheldon](https://github.com/bensheldon))
|
54
|
+
|
55
|
+
**Merged pull requests:**
|
56
|
+
|
57
|
+
- Remove v1.99/v2 transitional extra advisory lock [\#428](https://github.com/bensheldon/good_job/pull/428) ([bensheldon](https://github.com/bensheldon))
|
58
|
+
|
59
|
+
## [v2.4.1](https://github.com/bensheldon/good_job/tree/v2.4.1) (2021-10-11)
|
60
|
+
|
61
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.4.0...v2.4.1)
|
62
|
+
|
63
|
+
**Implemented enhancements:**
|
64
|
+
|
65
|
+
- Support Datadog APM / `dd-trace-rb` [\#323](https://github.com/bensheldon/good_job/issues/323)
|
66
|
+
- Display info about used timezone. [\#398](https://github.com/bensheldon/good_job/pull/398) ([morgoth](https://github.com/morgoth))
|
67
|
+
- Display cron schedules args in dashboard [\#396](https://github.com/bensheldon/good_job/pull/396) ([aried3r](https://github.com/aried3r))
|
68
|
+
|
69
|
+
**Fixed bugs:**
|
70
|
+
|
71
|
+
- Inline adapter should raise unhandled exceptions during execution [\#416](https://github.com/bensheldon/good_job/pull/416) ([bensheldon](https://github.com/bensheldon))
|
72
|
+
- Enforce english locale in UI [\#407](https://github.com/bensheldon/good_job/pull/407) ([morgoth](https://github.com/morgoth))
|
73
|
+
|
74
|
+
**Closed issues:**
|
75
|
+
|
76
|
+
- Finished jobs don't show up as finished [\#415](https://github.com/bensheldon/good_job/issues/415)
|
77
|
+
- Inline adapter should raise unhandled exceptions during execution [\#410](https://github.com/bensheldon/good_job/issues/410)
|
78
|
+
- Rewrite Scheduler "worker" thread name to be `thread` [\#406](https://github.com/bensheldon/good_job/issues/406)
|
79
|
+
- "WARNING: you don't own a lock of type ExclusiveLock" in Development [\#388](https://github.com/bensheldon/good_job/issues/388)
|
80
|
+
- Improve Readme's "Optimize queues, threads, processes" section [\#132](https://github.com/bensheldon/good_job/issues/132)
|
81
|
+
|
82
|
+
**Merged pull requests:**
|
83
|
+
|
84
|
+
- Ignore Rails HEAD Appraisal until `rails new` fixed [\#419](https://github.com/bensheldon/good_job/pull/419) ([bensheldon](https://github.com/bensheldon))
|
85
|
+
- Warn in Readme that configuration should not go into `config/initializers/*.rb` [\#418](https://github.com/bensheldon/good_job/pull/418) ([bensheldon](https://github.com/bensheldon))
|
86
|
+
- Replace worker wording [\#409](https://github.com/bensheldon/good_job/pull/409) ([Hugo-Hache](https://github.com/Hugo-Hache))
|
87
|
+
- Improve Readme's "Optimize queues, threads, processes" section [\#405](https://github.com/bensheldon/good_job/pull/405) ([Hugo-Hache](https://github.com/Hugo-Hache))
|
88
|
+
- Update GH Test Matrix with more PG versions [\#401](https://github.com/bensheldon/good_job/pull/401) ([tedhexaflow](https://github.com/tedhexaflow))
|
89
|
+
- Extract cron configuration hash into CronEntry ActiveModel objects [\#400](https://github.com/bensheldon/good_job/pull/400) ([bensheldon](https://github.com/bensheldon))
|
90
|
+
- Remove errant copy-paste from app.json [\#397](https://github.com/bensheldon/good_job/pull/397) ([morgoth](https://github.com/morgoth))
|
91
|
+
|
3
92
|
## [v2.4.0](https://github.com/bensheldon/good_job/tree/v2.4.0) (2021-10-02)
|
4
93
|
|
5
94
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.3.1...v2.4.0)
|
data/README.md
CHANGED
@@ -212,7 +212,11 @@ to delete old records and preserve space in your database.
|
|
212
212
|
|
213
213
|
To use GoodJob, you can set `config.active_job.queue_adapter` to a `:good_job`.
|
214
214
|
|
215
|
-
Additional configuration can be provided via `config.good_job.OPTION =
|
215
|
+
Additional configuration can be provided via `config.good_job.OPTION = ...`.
|
216
|
+
|
217
|
+
_Configuration **must** be placed into `config/application.rb` or `config/environments/{RAILS_ENV}.rb`; configuration may not work correctly if placed into `config/initializers/*.rb` because application initializers run _after_ gem initialization (see [Rails#36650](https://github.com/rails/rails/issues/36650) and [GoodJob#380](https://github.com/bensheldon/good_job/issues/380))._
|
218
|
+
|
219
|
+
Configuration examples:
|
216
220
|
|
217
221
|
```ruby
|
218
222
|
# config/application.rb
|
@@ -359,11 +363,19 @@ class MyJob < ApplicationJob
|
|
359
363
|
total_limit: 1,
|
360
364
|
|
361
365
|
# Or, if more control is needed:
|
362
|
-
# Maximum number of jobs with the concurrency key to be
|
366
|
+
# Maximum number of jobs with the concurrency key to be
|
367
|
+
# concurrently enqueued (excludes performing jobs)
|
363
368
|
enqueue_limit: 2,
|
364
|
-
|
369
|
+
|
370
|
+
# Maximum number of jobs with the concurrency key to be
|
371
|
+
# concurrently performed (excludes enqueued jobs)
|
365
372
|
perform_limit: 1,
|
366
373
|
|
374
|
+
# Note: Under heavy load, the total number of jobs may exceed the
|
375
|
+
# sum of `enqueue_limit` and `perform_limit` because of race conditions
|
376
|
+
# caused by imperfectly disjunctive states. If you need to constrain
|
377
|
+
# the total number of jobs, use `total_limit` instead. See #378.
|
378
|
+
|
367
379
|
# A unique key to be globally locked against.
|
368
380
|
# Can be String or Lambda/Proc that is invoked in the context of the job.
|
369
381
|
# Note: Arguments passed to #perform_later must be accessed through `arguments` method.
|
@@ -387,9 +399,9 @@ job.good_job_concurrency_key #=> "Unique-Alice"
|
|
387
399
|
|
388
400
|
GoodJob can enqueue jobs on a recurring basis that can be used as a replacement for cron.
|
389
401
|
|
390
|
-
Cron-style jobs are run on every GoodJob process (e.g. CLI or `async` execution mode) when `config.good_job.enable_cron = true
|
402
|
+
Cron-style jobs are run on every GoodJob process (e.g. CLI or `async` execution mode) when `config.good_job.enable_cron = true`, but GoodJob's cron uses unique indexes to ensure that only a single job is enqeued at the given time interval.
|
391
403
|
|
392
|
-
Cron-format is parsed by the [`fugit`](https://github.com/floraison/fugit) gem, which has support for seconds-level resolution (e.g. `* * * * * *`).
|
404
|
+
Cron-format is parsed by the [`fugit`](https://github.com/floraison/fugit) gem, which has support for seconds-level resolution (e.g. `* * * * * *`) and natural language parsing (e.g. `every second`).
|
393
405
|
|
394
406
|
```ruby
|
395
407
|
# config/environments/application.rb or a specific environment e.g. production.rb
|
@@ -576,43 +588,62 @@ end
|
|
576
588
|
|
577
589
|
By default, GoodJob creates a single thread execution pool that will execute jobs from any queue. Depending on your application's workload, job types, and service level objectives, you may wish to optimize execution resources. For example, providing dedicated execution resources for transactional emails so they are not delayed by long-running batch jobs. Some options:
|
578
590
|
|
579
|
-
- Multiple execution pools within a single process:
|
591
|
+
- Multiple isolated execution pools within a single process:
|
592
|
+
|
593
|
+
For moderate workloads, multiple isolated thread execution pools offers a good balance between congestion management and economy.
|
594
|
+
|
595
|
+
A pool is configured with the following syntax `<participating_queues>:<thread_count>`:
|
596
|
+
|
597
|
+
- `<participating_queues>`: either `queue1,queue2` (only those queues), `*` (all) or `-queue1,queue2` (all except those queues).
|
598
|
+
- `<thread_count>`: a count overriding for this specific pool the global `max-threads`.
|
599
|
+
|
600
|
+
Pool configurations are separated with a semicolon (;) in the `queues` configuration
|
580
601
|
|
581
602
|
```bash
|
582
|
-
$ bundle exec good_job
|
603
|
+
$ bundle exec good_job \
|
604
|
+
--queues="transactional_messages:2;batch_processing:1;-transactional_messages,batch_processing:2;*" \
|
605
|
+
--max-threads=5
|
583
606
|
```
|
584
607
|
|
585
|
-
This configuration will result in a single process with 4 isolated thread execution pools.
|
608
|
+
This configuration will result in a single process with 4 isolated thread execution pools.
|
586
609
|
|
587
|
-
- `transactional_messages:2`: execute jobs enqueued on `transactional_messages
|
588
|
-
- `batch_processing:1` execute jobs enqueued on `batch_processing
|
589
|
-
- `-transactional_messages,batch_processing`: execute jobs enqueued on _any_ queue _excluding_ `transactional_messages` or `batch_processing
|
590
|
-
- `*`: execute jobs on any queue
|
591
|
-
|
592
|
-
For moderate workloads, multiple isolated thread execution pools offers a good balance between congestion management and economy.
|
610
|
+
- `transactional_messages:2`: execute jobs enqueued on `transactional_messages`, with up to 2 threads.
|
611
|
+
- `batch_processing:1` execute jobs enqueued on `batch_processing`, with a single thread.
|
612
|
+
- `-transactional_messages,batch_processing`: execute jobs enqueued on _any_ queue _excluding_ `transactional_messages` or `batch_processing`, with up to 2 threads.
|
613
|
+
- `*`: execute jobs on any queue, with up to 5 threads (as configured by `--max-threads=5`).
|
593
614
|
|
594
615
|
Configuration can be injected by environment variables too:
|
595
616
|
|
596
617
|
```bash
|
597
|
-
$ GOOD_JOB_QUEUES="transactional_messages:2;batch_processing:1;-transactional_messages,batch_processing:2;*"
|
618
|
+
$ GOOD_JOB_QUEUES="transactional_messages:2;batch_processing:1;-transactional_messages,batch_processing:2;*" \
|
619
|
+
GOOD_JOB_MAX_THREADS=5 \
|
620
|
+
bundle exec good_job
|
598
621
|
```
|
599
622
|
|
600
|
-
- Multiple processes
|
623
|
+
- Multiple processes:
|
624
|
+
|
625
|
+
While multiple isolated thread execution pools offer a way to provide dedicated execution resources, those resources are bound to a single machine. To scale them independently, define several processes.
|
626
|
+
|
627
|
+
For example, this configuration on Heroku allows to customize the dyno count (instances), or type (CPU/RAM), per process type:
|
601
628
|
|
602
629
|
```procfile
|
603
630
|
# Procfile
|
604
631
|
|
605
|
-
# Separate
|
632
|
+
# Separate process types
|
606
633
|
worker: bundle exec good_job --max-threads=5
|
607
634
|
transactional_worker: bundle exec good_job --queues="transactional_messages" --max-threads=2
|
608
635
|
batch_worker: bundle exec good_job --queues="batch_processing" --max-threads=1
|
636
|
+
```
|
637
|
+
|
638
|
+
To optimize for CPU performance at the expense of greater memory and system resource usage, while keeping a single process type (and thus a single dyno), combine several processes and wait for them:
|
609
639
|
|
610
|
-
|
640
|
+
```procfile
|
641
|
+
# Procfile
|
642
|
+
|
643
|
+
# Combined multi-process
|
611
644
|
combined_worker: bundle exec good_job --max-threads=5 & bundle exec good_job --queues="transactional_messages" --max-threads=2 & bundle exec good_job --queues="batch_processing" --max-threads=1 & wait -n
|
612
645
|
```
|
613
646
|
|
614
|
-
Running multiple processes can optimize for CPU performance at the expense of greater memory and system resource usage.
|
615
|
-
|
616
647
|
Keep in mind, queue operations and management is an advanced discipline. This stuff is complex, especially for heavy workloads and unique processing requirements. Good job 👍
|
617
648
|
|
618
649
|
### Database connections
|