good_job 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -2
- data/lib/good_job/adapter.rb +6 -4
- data/lib/good_job/job.rb +2 -1
- data/lib/good_job/lockable.rb +8 -10
- data/lib/good_job/notifier.rb +25 -14
- data/lib/good_job/scheduler.rb +1 -0
- 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: b5125c48d26036d60649d0448f064aebcbe95fd90ac5e2eeb22e504761f7cdd1
|
4
|
+
data.tar.gz: f6cd3d0bcbfbbc639d0724557c7dbad61e9aef717545916b57a11c4413dcfe3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeb551e271b3a47aa903d64e566a010c87a632fd064835928d4986342405f458e02c5f88451c034ee2c73225274d54583ed963431e08e80232bcd3d87f76d500
|
7
|
+
data.tar.gz: f0c70c47ad3279bb41440ed27408511bdebc064524cf0933db066a0420bae829b1145b7713bc644febe0bc21e3010334f1c641863674110df878dd4245d17b7a
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,42 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.2.2](https://github.com/bensheldon/good_job/tree/v1.2.2) (2020-08-26)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.2.1...v1.2.2)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Run Github Action tests against Ruby 2.5, 2.6, 2.7 [\#100](https://github.com/bensheldon/good_job/issues/100)
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- Freezes puma on code change [\#95](https://github.com/bensheldon/good_job/issues/95)
|
14
|
+
- Ruby 2.7 keyword arguments warning [\#93](https://github.com/bensheldon/good_job/issues/93)
|
15
|
+
|
16
|
+
**Closed issues:**
|
17
|
+
|
18
|
+
- Add test for `rails g good\_job:install` [\#57](https://github.com/bensheldon/good_job/issues/57)
|
19
|
+
|
20
|
+
**Merged pull requests:**
|
21
|
+
|
22
|
+
- Use more ActiveRecord in Lockable and not connection.execute [\#102](https://github.com/bensheldon/good_job/pull/102) ([bensheldon](https://github.com/bensheldon))
|
23
|
+
- Run CI tests on Ruby 2.5, 2.6, and 2.7 [\#101](https://github.com/bensheldon/good_job/pull/101) ([arku](https://github.com/arku))
|
24
|
+
- Return to using executor.wrap around Scheduler execution task [\#99](https://github.com/bensheldon/good_job/pull/99) ([bensheldon](https://github.com/bensheldon))
|
25
|
+
- Fix Ruby 2.7 keyword arguments warning [\#98](https://github.com/bensheldon/good_job/pull/98) ([arku](https://github.com/arku))
|
26
|
+
- Remove executor/reloader for less interlocking [\#97](https://github.com/bensheldon/good_job/pull/97) ([sj26](https://github.com/sj26))
|
27
|
+
- Name the thread pools [\#96](https://github.com/bensheldon/good_job/pull/96) ([sj26](https://github.com/sj26))
|
28
|
+
- Add test for `rails g good\_job:install` [\#94](https://github.com/bensheldon/good_job/pull/94) ([arku](https://github.com/arku))
|
29
|
+
|
3
30
|
## [v1.2.1](https://github.com/bensheldon/good_job/tree/v1.2.1) (2020-08-21)
|
4
31
|
|
5
32
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.2.0...v1.2.1)
|
6
33
|
|
7
|
-
**
|
34
|
+
**Fixed bugs:**
|
8
35
|
|
9
36
|
- undefined method `thread\_mattr\_accessor' when not requiring the Sprockets Railstie [\#85](https://github.com/bensheldon/good_job/issues/85)
|
37
|
+
|
38
|
+
**Closed issues:**
|
39
|
+
|
10
40
|
- Document comparison of GoodJob with other backends [\#51](https://github.com/bensheldon/good_job/issues/51)
|
11
41
|
|
12
42
|
**Merged pull requests:**
|
@@ -47,7 +77,6 @@
|
|
47
77
|
|
48
78
|
**Merged pull requests:**
|
49
79
|
|
50
|
-
- Capture errors via instrumentation from retry\_on and discard\_on [\#79](https://github.com/bensheldon/good_job/pull/79) ([bensheldon](https://github.com/bensheldon))
|
51
80
|
- Document GoodJob::Scheduler with Yard [\#78](https://github.com/bensheldon/good_job/pull/78) ([bensheldon](https://github.com/bensheldon))
|
52
81
|
|
53
82
|
## [v1.1.2](https://github.com/bensheldon/good_job/tree/v1.1.2) (2020-08-13)
|
@@ -72,6 +101,7 @@
|
|
72
101
|
|
73
102
|
**Merged pull requests:**
|
74
103
|
|
104
|
+
- Capture errors via instrumentation from retry\_on and discard\_on [\#79](https://github.com/bensheldon/good_job/pull/79) ([bensheldon](https://github.com/bensheldon))
|
75
105
|
- Allow instantiation of multiple schedulers via --queues [\#76](https://github.com/bensheldon/good_job/pull/76) ([bensheldon](https://github.com/bensheldon))
|
76
106
|
- Extract options parsing to Configuration object [\#74](https://github.com/bensheldon/good_job/pull/74) ([bensheldon](https://github.com/bensheldon))
|
77
107
|
|
data/lib/good_job/adapter.rb
CHANGED
@@ -9,10 +9,12 @@ module GoodJob
|
|
9
9
|
end
|
10
10
|
|
11
11
|
configuration = GoodJob::Configuration.new(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
{
|
13
|
+
execution_mode: execution_mode,
|
14
|
+
queues: queues,
|
15
|
+
max_threads: max_threads,
|
16
|
+
poll_interval: poll_interval,
|
17
|
+
}
|
16
18
|
)
|
17
19
|
|
18
20
|
@execution_mode = configuration.execution_mode
|
data/lib/good_job/job.rb
CHANGED
@@ -58,7 +58,8 @@ module GoodJob
|
|
58
58
|
|
59
59
|
unfinished.priority_ordered.only_scheduled.limit(1).with_advisory_lock do |good_jobs|
|
60
60
|
good_job = good_jobs.first
|
61
|
-
|
61
|
+
# TODO: Determine why some records are fetched without an advisory lock at all
|
62
|
+
break unless good_job&.owns_advisory_lock?
|
62
63
|
|
63
64
|
result, error = good_job.perform
|
64
65
|
end
|
data/lib/good_job/lockable.rb
CHANGED
@@ -55,19 +55,17 @@ module GoodJob
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def advisory_lock
|
58
|
-
|
59
|
-
|
60
|
-
WHERE pg_try_advisory_lock(('x'||substr(md5(:table_name || :id::text), 1, 16))::bit(64)::bigint)
|
58
|
+
where_sql = <<~SQL
|
59
|
+
pg_try_advisory_lock(('x'||substr(md5(:table_name || :id::text), 1, 16))::bit(64)::bigint)
|
61
60
|
SQL
|
62
|
-
self.class.
|
61
|
+
self.class.unscoped.where(where_sql, { table_name: self.class.table_name, id: send(self.class.primary_key) }).exists?
|
63
62
|
end
|
64
63
|
|
65
64
|
def advisory_unlock
|
66
|
-
|
67
|
-
|
68
|
-
WHERE pg_advisory_unlock(('x'||substr(md5(:table_name || :id::text), 1, 16))::bit(64)::bigint)
|
65
|
+
where_sql = <<~SQL
|
66
|
+
pg_advisory_unlock(('x'||substr(md5(:table_name || :id::text), 1, 16))::bit(64)::bigint)
|
69
67
|
SQL
|
70
|
-
self.class.
|
68
|
+
self.class.unscoped.where(where_sql, { table_name: self.class.table_name, id: send(self.class.primary_key) }).exists?
|
71
69
|
end
|
72
70
|
|
73
71
|
def advisory_lock!
|
@@ -85,11 +83,11 @@ module GoodJob
|
|
85
83
|
end
|
86
84
|
|
87
85
|
def advisory_locked?
|
88
|
-
self.class.advisory_locked.where(id: send(self.class.primary_key)).
|
86
|
+
self.class.unscoped.advisory_locked.where(id: send(self.class.primary_key)).exists?
|
89
87
|
end
|
90
88
|
|
91
89
|
def owns_advisory_lock?
|
92
|
-
self.class.owns_advisory_locked.where(id: send(self.class.primary_key)).
|
90
|
+
self.class.unscoped.owns_advisory_locked.where(id: send(self.class.primary_key)).exists?
|
93
91
|
end
|
94
92
|
|
95
93
|
def advisory_unlock!
|
data/lib/good_job/notifier.rb
CHANGED
@@ -7,6 +7,7 @@ module GoodJob # :nodoc:
|
|
7
7
|
class Notifier
|
8
8
|
CHANNEL = 'good_job'.freeze
|
9
9
|
POOL_OPTIONS = {
|
10
|
+
name: name,
|
10
11
|
min_threads: 0,
|
11
12
|
max_threads: 1,
|
12
13
|
auto_terminate: true,
|
@@ -69,13 +70,12 @@ module GoodJob # :nodoc:
|
|
69
70
|
|
70
71
|
def listen
|
71
72
|
future = Concurrent::Future.new(args: [@recipients, @pool, @listening], executor: @pool) do |recipients, pool, listening|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
begin
|
74
|
+
with_listen_connection do |conn|
|
75
|
+
ActiveSupport::Notifications.instrument("notifier_listen.good_job") do
|
76
|
+
conn.async_exec "LISTEN #{CHANNEL}"
|
77
|
+
end
|
77
78
|
|
78
|
-
begin
|
79
79
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
80
80
|
while pool.running?
|
81
81
|
listening.make_true
|
@@ -93,14 +93,14 @@ module GoodJob # :nodoc:
|
|
93
93
|
listening.make_false
|
94
94
|
end
|
95
95
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
96
|
+
end
|
97
|
+
rescue StandardError => e
|
98
|
+
ActiveSupport::Notifications.instrument("notifier_notify_error.good_job", { error: e })
|
99
|
+
raise
|
100
|
+
ensure
|
101
|
+
@listening.make_false
|
102
|
+
ActiveSupport::Notifications.instrument("notifier_unlisten.good_job") do
|
103
|
+
conn.async_exec "UNLISTEN *"
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -112,5 +112,16 @@ module GoodJob # :nodoc:
|
|
112
112
|
def listen_observer(_time, _result, _thread_error)
|
113
113
|
listen unless shutdown?
|
114
114
|
end
|
115
|
+
|
116
|
+
def with_listen_connection
|
117
|
+
ar_conn = ActiveRecord::Base.connection_pool.checkout.tap do |conn|
|
118
|
+
ActiveRecord::Base.connection_pool.remove(conn)
|
119
|
+
end
|
120
|
+
pg_conn = ar_conn.raw_connection
|
121
|
+
pg_conn.exec("SET application_name = #{pg_conn.escape_identifier(self.class.name)}")
|
122
|
+
yield pg_conn
|
123
|
+
ensure
|
124
|
+
ar_conn.disconnect!
|
125
|
+
end
|
115
126
|
end
|
116
127
|
end
|
data/lib/good_job/scheduler.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|