good_job 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba54d04d3afa9fea7af913fb6e04f3bdbc104f47a57b629001071da7fcd4ed55
4
- data.tar.gz: 2bd4dd5be31a15c43d58f0ab7cd33830834e1e2bcd0506445258aa75d4cc98e5
3
+ metadata.gz: 86268c6767ba44783707ed768fe726b7a53592e46468ed49bd38d427ff4919af
4
+ data.tar.gz: 5fa72a4aaec59a31ba437eac31f9a6785cdb548c6694bea332434baf58aaad98
5
5
  SHA512:
6
- metadata.gz: 8ade9720ef3918e10d129e886411b819e8fd96614a299552d68287ed43fcab2997057b8c63ee26b35ac321cf7d58a055c7cf5b14f74f3c887b14f59934537be8
7
- data.tar.gz: 9f81f5e7faacbe1b6a4999fa82afa6eb03675472c0237616f6f570c235f72c8c925fbea0ff526726bb6542c795ef47feaa61b5e9dd00520d6a38fbfa4b7463a5
6
+ metadata.gz: c63baa745a861101b1a65c7a2dd7f4ec603a50714d5952a7ad942f30b41543643e6b7e1f19b1373f280668f212c6e173c4aa90d7d3a0770a92c1e159ae30215b
7
+ data.tar.gz: 7bf564c4cfc0804f1a32995214195736e9cbd8d8f7a5b45d3ffe7efecf3d43126d412594855d50c9637c646e82838112a4869a4732fa0fe5ba1542b558facd0f
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.7.1](https://github.com/bensheldon/good_job/tree/v1.7.1) (2021-01-27)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.7.0...v1.7.1)
6
+
7
+ **Closed issues:**
8
+
9
+ - Unexpected behavior with max\_threads = 1 [\#208](https://github.com/bensheldon/good_job/issues/208)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Scheduler should always push a new task on completion of previous task, regardless of available thread calculation [\#209](https://github.com/bensheldon/good_job/pull/209) ([bensheldon](https://github.com/bensheldon))
14
+ - Fix equality typo in development.rb of test\_app [\#207](https://github.com/bensheldon/good_job/pull/207) ([reczy](https://github.com/reczy))
15
+
3
16
  ## [v1.7.0](https://github.com/bensheldon/good_job/tree/v1.7.0) (2021-01-25)
4
17
 
5
18
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.6.0...v1.7.0)
@@ -101,6 +114,7 @@
101
114
 
102
115
  - Ensure advisory lock CTE is MATERIALIZED on Postgres v12+ [\#179](https://github.com/bensheldon/good_job/pull/179) ([bensheldon](https://github.com/bensheldon))
103
116
  - Ensure that deleted jobs are unlocked [\#178](https://github.com/bensheldon/good_job/pull/178) ([bensheldon](https://github.com/bensheldon))
117
+ - Fix job ordering for Rails 6.1 [\#174](https://github.com/bensheldon/good_job/pull/174) ([morgoth](https://github.com/morgoth))
104
118
 
105
119
  **Closed issues:**
106
120
 
@@ -115,10 +129,6 @@
115
129
 
116
130
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.3.3...v1.3.4)
117
131
 
118
- **Fixed bugs:**
119
-
120
- - Fix job ordering for Rails 6.1 [\#174](https://github.com/bensheldon/good_job/pull/174) ([morgoth](https://github.com/morgoth))
121
-
122
132
  ## [v1.3.3](https://github.com/bensheldon/good_job/tree/v1.3.3) (2020-12-01)
123
133
 
124
134
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.3.2...v1.3.3)
@@ -23,7 +23,7 @@ module GoodJob # :nodoc:
23
23
  max_threads: Configuration::DEFAULT_MAX_THREADS,
24
24
  auto_terminate: true,
25
25
  idletime: 60,
26
- max_queue: 1, # ideally zero, but 0 == infinite
26
+ max_queue: Configuration::DEFAULT_MAX_THREADS,
27
27
  fallback_policy: :discard,
28
28
  }.freeze
29
29
 
@@ -71,7 +71,10 @@ module GoodJob # :nodoc:
71
71
 
72
72
  @max_cache = max_cache || 0
73
73
  @pool_options = DEFAULT_POOL_OPTIONS.dup
74
- @pool_options[:max_threads] = max_threads if max_threads.present?
74
+ if max_threads.present?
75
+ @pool_options[:max_threads] = max_threads
76
+ @pool_options[:max_queue] = max_threads
77
+ end
75
78
  @pool_options[:name] = "GoodJob::Scheduler(queues=#{@performer.name} max_threads=#{@pool_options[:max_threads]})"
76
79
 
77
80
  create_pool
@@ -163,7 +166,7 @@ module GoodJob # :nodoc:
163
166
  def task_observer(time, output, thread_error)
164
167
  GoodJob.on_thread_error.call(thread_error) if thread_error && GoodJob.on_thread_error.respond_to?(:call)
165
168
  instrument("finished_job_task", { result: output, error: thread_error, time: time })
166
- create_thread if output
169
+ create_task if output
167
170
  end
168
171
 
169
172
  def warm_cache
@@ -181,11 +184,11 @@ module GoodJob # :nodoc:
181
184
  {
182
185
  name: @performer.name,
183
186
  max_threads: @pool_options[:max_threads],
184
- active_threads: @pool.ready_worker_count - @pool_options[:max_threads],
185
- inactive_threads: @pool.ready_worker_count,
187
+ active_threads: @pool_options[:max_threads] - @pool.ready_worker_count,
188
+ available_threads: @pool.ready_worker_count,
186
189
  max_cache: @max_cache,
187
- cache_count: cache_count,
188
- cache_remaining: remaining_cache_count,
190
+ active_cache: cache_count,
191
+ available_cache: remaining_cache_count,
189
192
  }
190
193
  end
191
194
 
@@ -200,6 +203,16 @@ module GoodJob # :nodoc:
200
203
  end
201
204
  end
202
205
 
206
+ def create_task(delay = 0)
207
+ future = Concurrent::ScheduledTask.new(delay, args: [@performer], executor: @pool, timer_set: timer_set) do |performer|
208
+ output = nil
209
+ Rails.application.executor.wrap { output = performer.next }
210
+ output
211
+ end
212
+ future.add_observer(self, :task_observer)
213
+ future.execute
214
+ end
215
+
203
216
  def instrument(name, payload = {}, &block)
204
217
  payload = payload.reverse_merge({
205
218
  scheduler: self,
@@ -1,4 +1,4 @@
1
1
  module GoodJob
2
2
  # GoodJob gem version.
3
- VERSION = '1.7.0'.freeze
3
+ VERSION = '1.7.1'.freeze
4
4
  end
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.7.0
4
+ version: 1.7.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-01-25 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob