good_job 1.12.0 → 1.12.1
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 +46 -1
- data/lib/good_job.rb +3 -3
- 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: 5b4629010561604c4f1d77812c3ca7301e5600fa8e0637fd584a769898d43aa5
|
4
|
+
data.tar.gz: 1216b9d590c40c047fa25c13afec94021891752bab8ec36ff7f6c968af8e285e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef51328facf01deeec6a2e67c38c526c944d1c7381fa45cf97f7f05aa4897ac711c324f616e8d948c3c5e6e4e5fae636ea2c7c3c9d48d79de0ead78ed438580f
|
7
|
+
data.tar.gz: e4efa15858ac7a6c0849ec084a00de8fbb8f6751523e78c9234b118bee2c84f3709c549cfc1f161af5166b2d54ff1f358b2dbd18e54adca06d6c62ad10757827
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.12.1](https://github.com/bensheldon/good_job/tree/v1.12.1) (2021-08-05)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.12.0...v1.12.1)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Ensure CLI can shutdown cleanly with multiple queues and timeout [\#319](https://github.com/bensheldon/good_job/pull/319) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- Setting a shutdown timeout causes the CLI executor to throw an exception on shutdown. [\#318](https://github.com/bensheldon/good_job/issues/318)
|
14
|
+
- PgBouncer and prepared statements [\#269](https://github.com/bensheldon/good_job/issues/269)
|
15
|
+
- Question about locking internals [\#212](https://github.com/bensheldon/good_job/issues/212)
|
16
|
+
- Encoding::UndefinedConversionError \("\xE2" from ASCII-8BIT to UTF-8\) [\#198](https://github.com/bensheldon/good_job/issues/198)
|
17
|
+
- tools for managing a 'fleet' of processes [\#150](https://github.com/bensheldon/good_job/issues/150)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Fix Readme lint warnings [\#320](https://github.com/bensheldon/good_job/pull/320) ([bensheldon](https://github.com/bensheldon))
|
22
|
+
|
3
23
|
## [v1.12.0](https://github.com/bensheldon/good_job/tree/v1.12.0) (2021-07-27)
|
4
24
|
|
5
25
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.11.3...v1.12.0)
|
data/README.md
CHANGED
@@ -52,6 +52,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
52
52
|
- [Execute jobs async / in-process](#execute-jobs-async--in-process)
|
53
53
|
- [Migrate to GoodJob from a different ActiveJob backend](#migrate-to-goodjob-from-a-different-activejob-backend)
|
54
54
|
- [Monitor and preserve worked jobs](#monitor-and-preserve-worked-jobs)
|
55
|
+
- [PgBouncer compatibility](#pgbouncer-compatibility)
|
55
56
|
- [Contribute](#contribute)
|
56
57
|
- [Gem development](#gem-development)
|
57
58
|
- [Release](#release)
|
@@ -334,7 +335,7 @@ GoodJob includes a Dashboard as a mountable `Rails::Engine`.
|
|
334
335
|
|
335
336
|
### ActiveJob concurrency
|
336
337
|
|
337
|
-
GoodJob can extend ActiveJob to provide limits on concurrently running jobs, either at time of _enqueue_ or at _perform_.
|
338
|
+
GoodJob can extend ActiveJob to provide limits on concurrently running jobs, either at time of _enqueue_ or at _perform_. Limiting concurrency can help prevent duplicate, double or unecessary jobs from being enqueued, or race conditions when performing, for example when interacting with 3rd-party APIs.
|
338
339
|
|
339
340
|
**Note:** Limiting concurrency at _enqueue_ requires Rails 6.0+ because Rails 5.2 does not support `throw :abort` in ActiveJob callbacks.
|
340
341
|
|
@@ -361,6 +362,13 @@ class MyJob < ApplicationJob
|
|
361
362
|
end
|
362
363
|
```
|
363
364
|
|
365
|
+
When testing, the resulting concurrency key value can be inspected:
|
366
|
+
|
367
|
+
```ruby
|
368
|
+
job = MyJob.perform_later("Alice")
|
369
|
+
job.good_job_concurrency_key #=> "Unique-Alice"
|
370
|
+
```
|
371
|
+
|
364
372
|
### Cron-style repeating/recurring jobs
|
365
373
|
|
366
374
|
GoodJob can enqueue jobs on a recurring basis that can be used as a replacement for cron.
|
@@ -680,6 +688,43 @@ It is also necessary to delete these preserved jobs from the database after a ce
|
|
680
688
|
$ bundle exec good_job cleanup_preserved_jobs --before-seconds-ago=86400
|
681
689
|
```
|
682
690
|
|
691
|
+
### PgBouncer compatibility
|
692
|
+
|
693
|
+
GoodJob is not compatible with PgBouncer in _transaction_ mode, but is compatible with PgBouncer's _connection_ mode. GoodJob uses connection-based advisory locks and LISTEN/NOTIFY, both of which require full database connections.
|
694
|
+
|
695
|
+
A workaround to this limitation is to make a direct database connection available to GoodJob. With Rails 6.0's support for [multiple databases](https://guides.rubyonrails.org/active_record_multiple_databases.html), a direct connection to the database can be configured:
|
696
|
+
|
697
|
+
1. Define a direct connection to your database that is not proxied through PgBouncer, for example:
|
698
|
+
|
699
|
+
```yml
|
700
|
+
# config/database.yml
|
701
|
+
|
702
|
+
production:
|
703
|
+
primary:
|
704
|
+
url: postgres://pgbouncer_host/my_database
|
705
|
+
primary_direct:
|
706
|
+
url: postgres://database_host/my_database
|
707
|
+
```
|
708
|
+
|
709
|
+
1. Create a new ActiveRecord base class that uses the direct database connection
|
710
|
+
|
711
|
+
```ruby
|
712
|
+
# app/models/application_direct_record.rb
|
713
|
+
|
714
|
+
class ApplicationDirectRecord < ActiveRecord::Base
|
715
|
+
self.abstract_class = true
|
716
|
+
connects_to database: :primary_direct
|
717
|
+
end
|
718
|
+
```
|
719
|
+
|
720
|
+
1. Configure GoodJob to use the newly created ActiveRecord base class:
|
721
|
+
|
722
|
+
```ruby
|
723
|
+
# config/initializers/good_job.rb
|
724
|
+
|
725
|
+
GoodJob.active_record_parent_class = "ApplicationDirectRecord"
|
726
|
+
```
|
727
|
+
|
683
728
|
## Contribute
|
684
729
|
|
685
730
|
Contributions are welcomed and appreciated 🙏
|
data/lib/good_job.rb
CHANGED
@@ -126,13 +126,13 @@ module GoodJob
|
|
126
126
|
_shutdown_all(_executables, :restart, timeout: timeout)
|
127
127
|
end
|
128
128
|
|
129
|
-
# Sends +#shutdown+ or +#restart+ to executable objects ({GoodJob::Notifier}, {GoodJob::Poller}, {GoodJob::Scheduler})
|
130
|
-
# @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler>] Objects to shut down.
|
129
|
+
# Sends +#shutdown+ or +#restart+ to executable objects ({GoodJob::Notifier}, {GoodJob::Poller}, {GoodJob::Scheduler}, {GoodJob::MultiScheduler}, {GoodJob::CronManager})
|
130
|
+
# @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler, CronManager>] Objects to shut down.
|
131
131
|
# @param method_name [:symbol] Method to call, e.g. +:shutdown+ or +:restart+.
|
132
132
|
# @param timeout [nil,Numeric]
|
133
133
|
# @return [void]
|
134
134
|
def self._shutdown_all(executables, method_name = :shutdown, timeout: -1)
|
135
|
-
if timeout.positive?
|
135
|
+
if timeout.is_a?(Numeric) && timeout.positive?
|
136
136
|
executables.each { |executable| executable.send(method_name, timeout: nil) }
|
137
137
|
|
138
138
|
stop_at = Time.current + timeout
|
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: 1.12.
|
4
|
+
version: 1.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|