good_job 1.3.6 → 1.4.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 +13 -1
- data/README.md +7 -0
- data/lib/good_job/lockable.rb +19 -6
- data/lib/good_job/notifier.rb +6 -0
- data/lib/good_job/scheduler.rb +8 -5
- data/lib/good_job/version.rb +1 -1
- metadata +2 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a970811c9e009e460f65ed53b23913ae530e2a4018811ed63aa382ac673ad8a
|
4
|
+
data.tar.gz: 5678206af710fdbc275486529451356ae7ab8b2f52c64e8743db4789c806319d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a1cc256e46120045b1c5f9583c9c9f6ee948a60b8e3a0f4a0dd6ee74be411dbe3d8303c6b8c0c536804f563b8819174a3840814a66f4e4110ba25244a25cffb
|
7
|
+
data.tar.gz: 11224d38b15c50108e14e529f645de8e9991aeb265414fea4513aaa253da6c13fcc9b981132516497db53f185430bb1b775ee1f5964cd8d9ece528a9a5353f70
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.4.0](https://github.com/bensheldon/good_job/tree/v1.4.0) (2020-12-31)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.3.6...v1.4.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Add JRuby support [\#167](https://github.com/bensheldon/good_job/pull/167) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- JRuby Support [\#160](https://github.com/bensheldon/good_job/issues/160)
|
14
|
+
|
3
15
|
## [v1.3.6](https://github.com/bensheldon/good_job/tree/v1.3.6) (2020-12-30)
|
4
16
|
|
5
17
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.3.5...v1.3.6)
|
@@ -89,7 +101,6 @@
|
|
89
101
|
- Fix Ruby 2.7 GH action by setting default bundler explicitly [\#166](https://github.com/bensheldon/good_job/pull/166) ([bensheldon](https://github.com/bensheldon))
|
90
102
|
- Cache ruby version explicitly in Github Action [\#165](https://github.com/bensheldon/good_job/pull/165) ([bensheldon](https://github.com/bensheldon))
|
91
103
|
- Update development dependencies, rubocop [\#164](https://github.com/bensheldon/good_job/pull/164) ([bensheldon](https://github.com/bensheldon))
|
92
|
-
- Fix intended constant hierarchy of GoodJob::Scheduler::ThreadPoolExecutor [\#158](https://github.com/bensheldon/good_job/pull/158) ([bensheldon](https://github.com/bensheldon))
|
93
104
|
- Add bin/test\_app executable for Rails debugging [\#157](https://github.com/bensheldon/good_job/pull/157) ([bensheldon](https://github.com/bensheldon))
|
94
105
|
- Extract Scheduler polling behavior to its own object [\#152](https://github.com/bensheldon/good_job/pull/152) ([bensheldon](https://github.com/bensheldon))
|
95
106
|
|
@@ -124,6 +135,7 @@
|
|
124
135
|
|
125
136
|
**Merged pull requests:**
|
126
137
|
|
138
|
+
- Fix intended constant hierarchy of GoodJob::Scheduler::ThreadPoolExecutor [\#158](https://github.com/bensheldon/good_job/pull/158) ([bensheldon](https://github.com/bensheldon))
|
127
139
|
- Add info how to setup basic auth for engine [\#153](https://github.com/bensheldon/good_job/pull/153) ([morgoth](https://github.com/morgoth))
|
128
140
|
- Add documentation for Dashboard Rails::Engine [\#149](https://github.com/bensheldon/good_job/pull/149) ([bensheldon](https://github.com/bensheldon))
|
129
141
|
- Style cleanup to Job error handling [\#147](https://github.com/bensheldon/good_job/pull/147) ([bensheldon](https://github.com/bensheldon))
|
data/README.md
CHANGED
@@ -30,6 +30,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
30
30
|
## Table of contents
|
31
31
|
|
32
32
|
- [Set up](#set-up)
|
33
|
+
- [Compatibility](#compatibility)
|
33
34
|
- [Configuration](#configuration)
|
34
35
|
- [Command-line options](#command-line-options)
|
35
36
|
- [`good_job start`](#good_job-start)
|
@@ -123,6 +124,12 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
123
124
|
|
124
125
|
Additional configuration is likely necessary, see the reference below for async configuration.
|
125
126
|
|
127
|
+
## Compatibility
|
128
|
+
|
129
|
+
- **Ruby on Rails:** 5.2+
|
130
|
+
- **Ruby:** MRI 2.5+. JRuby 9.13+ (_JRuby's `activerecord-jdbcpostgresql-adapter` gem does not support Postgres LISTEN/NOTIFY)._
|
131
|
+
- **Postgres:** 9.6+
|
132
|
+
|
126
133
|
## Configuration
|
127
134
|
|
128
135
|
### Command-line options
|
data/lib/good_job/lockable.rb
CHANGED
@@ -157,7 +157,8 @@ module GoodJob
|
|
157
157
|
SELECT 1 AS one
|
158
158
|
WHERE pg_try_advisory_lock(('x'||substr(md5($1 || $2::text), 1, 16))::bit(64)::bigint)
|
159
159
|
SQL
|
160
|
-
|
160
|
+
binds = [[nil, self.class.table_name], [nil, send(self.class.primary_key)]]
|
161
|
+
ActiveRecord::Base.connection.exec_query(pg_or_jdbc_query(query), 'GoodJob::Lockable Advisory Lock', binds).any?
|
161
162
|
end
|
162
163
|
|
163
164
|
# Releases an advisory lock on this record if it is locked by this database
|
@@ -169,7 +170,8 @@ module GoodJob
|
|
169
170
|
SELECT 1 AS one
|
170
171
|
WHERE pg_advisory_unlock(('x'||substr(md5($1 || $2::text), 1, 16))::bit(64)::bigint)
|
171
172
|
SQL
|
172
|
-
|
173
|
+
binds = [[nil, self.class.table_name], [nil, send(self.class.primary_key)]]
|
174
|
+
self.class.connection.exec_query(pg_or_jdbc_query(query), 'GoodJob::Lockable Advisory Unlock', binds).any?
|
173
175
|
end
|
174
176
|
|
175
177
|
# Acquires an advisory lock on this record or raises
|
@@ -212,9 +214,10 @@ module GoodJob
|
|
212
214
|
WHERE pg_locks.locktype = 'advisory'
|
213
215
|
AND pg_locks.objsubid = 1
|
214
216
|
AND pg_locks.classid = ('x' || substr(md5($1 || $2::text), 1, 16))::bit(32)::int
|
215
|
-
AND pg_locks.objid = (('x' || substr(md5($
|
217
|
+
AND pg_locks.objid = (('x' || substr(md5($3 || $4::text), 1, 16))::bit(64) << 32)::bit(32)::int
|
216
218
|
SQL
|
217
|
-
self.class.
|
219
|
+
binds = [[nil, self.class.table_name], [nil, send(self.class.primary_key)], [nil, self.class.table_name], [nil, send(self.class.primary_key)]]
|
220
|
+
self.class.connection.exec_query(pg_or_jdbc_query(query), 'GoodJob::Lockable Advisory Locked?', binds).any?
|
218
221
|
end
|
219
222
|
|
220
223
|
# Tests whether this record is locked by the current database session.
|
@@ -226,10 +229,11 @@ module GoodJob
|
|
226
229
|
WHERE pg_locks.locktype = 'advisory'
|
227
230
|
AND pg_locks.objsubid = 1
|
228
231
|
AND pg_locks.classid = ('x' || substr(md5($1 || $2::text), 1, 16))::bit(32)::int
|
229
|
-
AND pg_locks.objid = (('x' || substr(md5($
|
232
|
+
AND pg_locks.objid = (('x' || substr(md5($3 || $4::text), 1, 16))::bit(64) << 32)::bit(32)::int
|
230
233
|
AND pg_locks.pid = pg_backend_pid()
|
231
234
|
SQL
|
232
|
-
self.class.
|
235
|
+
binds = [[nil, self.class.table_name], [nil, send(self.class.primary_key)], [nil, self.class.table_name], [nil, send(self.class.primary_key)]]
|
236
|
+
self.class.connection.exec_query(pg_or_jdbc_query(query), 'GoodJob::Lockable Owns Advisory Lock?', binds).any?
|
233
237
|
end
|
234
238
|
|
235
239
|
# Releases all advisory locks on the record that are held by the current
|
@@ -245,5 +249,14 @@ module GoodJob
|
|
245
249
|
# Made public in Rails 5.2
|
246
250
|
self.class.send(:sanitize_sql_for_conditions, *args)
|
247
251
|
end
|
252
|
+
|
253
|
+
def pg_or_jdbc_query(query)
|
254
|
+
if Concurrent.on_jruby?
|
255
|
+
# Replace $1 bind parameters with ?
|
256
|
+
query.gsub(/\$\d*/, '?')
|
257
|
+
else
|
258
|
+
query
|
259
|
+
end
|
260
|
+
end
|
248
261
|
end
|
249
262
|
end
|
data/lib/good_job/notifier.rb
CHANGED
@@ -9,6 +9,8 @@ module GoodJob # :nodoc:
|
|
9
9
|
# When a message is received, the notifier passes the message to each of its recipients.
|
10
10
|
#
|
11
11
|
class Notifier
|
12
|
+
AdapterCannotListenError = Class.new(StandardError)
|
13
|
+
|
12
14
|
# Default Postgres channel for LISTEN/NOTIFY
|
13
15
|
CHANNEL = 'good_job'.freeze
|
14
16
|
# Defaults for instance of Concurrent::ThreadPoolExecutor
|
@@ -94,6 +96,8 @@ module GoodJob # :nodoc:
|
|
94
96
|
# @!visibility private
|
95
97
|
# @return [void]
|
96
98
|
def listen_observer(_time, _result, thread_error)
|
99
|
+
return if thread_error.is_a? AdapterCannotListenError
|
100
|
+
|
97
101
|
if thread_error
|
98
102
|
GoodJob.on_thread_error.call(thread_error) if GoodJob.on_thread_error.respond_to?(:call)
|
99
103
|
ActiveSupport::Notifications.instrument("notifier_notify_error.good_job", { error: thread_error })
|
@@ -149,6 +153,8 @@ module GoodJob # :nodoc:
|
|
149
153
|
ActiveRecord::Base.connection_pool.remove(conn)
|
150
154
|
end
|
151
155
|
pg_conn = ar_conn.raw_connection
|
156
|
+
raise AdapterCannotListenError unless pg_conn.respond_to? :wait_for_notify
|
157
|
+
|
152
158
|
pg_conn.async_exec("SET application_name = #{pg_conn.escape_identifier(self.class.name)}").clear
|
153
159
|
yield pg_conn
|
154
160
|
ensure
|
data/lib/good_job/scheduler.rb
CHANGED
@@ -22,7 +22,7 @@ module GoodJob # :nodoc:
|
|
22
22
|
max_threads: Configuration::DEFAULT_MAX_THREADS,
|
23
23
|
auto_terminate: true,
|
24
24
|
idletime: 60,
|
25
|
-
max_queue:
|
25
|
+
max_queue: 0,
|
26
26
|
fallback_policy: :discard,
|
27
27
|
}.freeze
|
28
28
|
|
@@ -170,10 +170,13 @@ module GoodJob # :nodoc:
|
|
170
170
|
# @return [Integer]
|
171
171
|
def ready_worker_count
|
172
172
|
synchronize do
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
173
|
+
if Concurrent.on_jruby?
|
174
|
+
@executor.getMaximumPoolSize - @executor.getActiveCount
|
175
|
+
else
|
176
|
+
workers_still_to_be_created = @max_length - @pool.length
|
177
|
+
workers_created_but_waiting = @ready.length
|
178
|
+
workers_still_to_be_created + workers_created_but_waiting
|
179
|
+
end
|
177
180
|
end
|
178
181
|
end
|
179
182
|
end
|
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.
|
4
|
+
version: 1.4.0
|
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-12-
|
11
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.2
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pg
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.0
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: railties
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,34 +248,6 @@ dependencies:
|
|
262
248
|
- - ">="
|
263
249
|
- !ruby/object:Gem::Version
|
264
250
|
version: '0'
|
265
|
-
- !ruby/object:Gem::Dependency
|
266
|
-
name: rails
|
267
|
-
requirement: !ruby/object:Gem::Requirement
|
268
|
-
requirements:
|
269
|
-
- - ">="
|
270
|
-
- !ruby/object:Gem::Version
|
271
|
-
version: '0'
|
272
|
-
type: :development
|
273
|
-
prerelease: false
|
274
|
-
version_requirements: !ruby/object:Gem::Requirement
|
275
|
-
requirements:
|
276
|
-
- - ">="
|
277
|
-
- !ruby/object:Gem::Version
|
278
|
-
version: '0'
|
279
|
-
- !ruby/object:Gem::Dependency
|
280
|
-
name: rbtrace
|
281
|
-
requirement: !ruby/object:Gem::Requirement
|
282
|
-
requirements:
|
283
|
-
- - ">="
|
284
|
-
- !ruby/object:Gem::Version
|
285
|
-
version: '0'
|
286
|
-
type: :development
|
287
|
-
prerelease: false
|
288
|
-
version_requirements: !ruby/object:Gem::Requirement
|
289
|
-
requirements:
|
290
|
-
- - ">="
|
291
|
-
- !ruby/object:Gem::Version
|
292
|
-
version: '0'
|
293
251
|
- !ruby/object:Gem::Dependency
|
294
252
|
name: rspec-rails
|
295
253
|
requirement: !ruby/object:Gem::Requirement
|