good_job 3.4.2 → 3.4.3

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: 6c31e9dc63de3bff82d55ba85e17690ad52dcf2d9b8ebc8bcb0d8dc7eab261b0
4
- data.tar.gz: bab18a8d7b7328f172a6b66adba1767281cba281a8f38e76c8bfd303fd6a25a9
3
+ metadata.gz: 8838f9cf09b7dda04c3dc119db41deef4facc8b31a07e879e082898d77915d8d
4
+ data.tar.gz: a7e146e678ea6432f291f593edfce11497b70201576e299360a026dc83290dda
5
5
  SHA512:
6
- metadata.gz: d93aa0c5246d5e7be37f5887b7b3c8618815b88558360bb351ce9df7529460994506ddbdd84f1c57d4066216ea0fa98afdb937468c60aafd4966a2de88967656
7
- data.tar.gz: b25da80ce2ca30517c4ec89187e062db7c1fd1e0b16ce7adaec33fb7da53ce1d56163a58595b57b4919d9d9cdbdf81ef6cf61664c48d2940c1f06fc70aaa6589
6
+ metadata.gz: 87a1770d3b74c50c6a40bc63ca50ad368578524029b8d11b5221baf721f7c8169051f0c19bc9554962ff61fc9cf51ac397f042ad393a4c19cecb73924db0c6c2
7
+ data.tar.gz: d707c9b35f41b417628425c74e916c21654992dcb41a27e52fdc88435e74fae09168b85bea81470aeba7eb2236b9d2d57a736ce4c34a5c427c4f82230146d7fa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.4.3](https://github.com/bensheldon/good_job/tree/v3.4.3) (2022-08-15)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.4.2...v3.4.3)
6
+
7
+ **Closed issues:**
8
+
9
+ - How to run multiple workers? [\#699](https://github.com/bensheldon/good_job/issues/699)
10
+ - Getting Postgres Errors on killing development server after setting up Goodjob [\#692](https://github.com/bensheldon/good_job/issues/692)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Fix Project v2 GitHub Actions [\#701](https://github.com/bensheldon/good_job/pull/701) ([bensheldon](https://github.com/bensheldon))
15
+ - Remove development dependencies: memory\_profiler, rbtrace, sigdump [\#700](https://github.com/bensheldon/good_job/pull/700) ([bensheldon](https://github.com/bensheldon))
16
+ - Allow concurrency limits to be configured dynamically with lambda/proc [\#696](https://github.com/bensheldon/good_job/pull/696) ([baka-san](https://github.com/baka-san))
17
+ - Add additional details to Concurrency Control explanation [\#695](https://github.com/bensheldon/good_job/pull/695) ([bensheldon](https://github.com/bensheldon))
18
+
3
19
  ## [v3.4.2](https://github.com/bensheldon/good_job/tree/v3.4.2) (2022-08-13)
4
20
 
5
21
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.4.1...v3.4.2)
@@ -18,7 +34,7 @@
18
34
 
19
35
  **Merged pull requests:**
20
36
 
21
- - Enqueues jobs with I18n default locale [\#698](https://github.com/bensheldon/good_job/pull/698) ([esasse](https://github.com/esasse))
37
+ - Enqueues Cron jobs with I18n default locale [\#698](https://github.com/bensheldon/good_job/pull/698) ([esasse](https://github.com/esasse))
22
38
 
23
39
  ## [v3.4.1](https://github.com/bensheldon/good_job/tree/v3.4.1) (2022-08-06)
24
40
 
data/README.md CHANGED
@@ -406,15 +406,18 @@ class MyJob < ApplicationJob
406
406
 
407
407
  good_job_control_concurrency_with(
408
408
  # Maximum number of unfinished jobs to allow with the concurrency key
409
+ # Can be an Integer or Lambda/Proc that is invoked in the context of the job
409
410
  total_limit: 1,
410
411
 
411
412
  # Or, if more control is needed:
412
413
  # Maximum number of jobs with the concurrency key to be
413
414
  # concurrently enqueued (excludes performing jobs)
415
+ # Can be an Integer or Lambda/Proc that is invoked in the context of the job
414
416
  enqueue_limit: 2,
415
417
 
416
418
  # Maximum number of jobs with the concurrency key to be
417
419
  # concurrently performed (excludes enqueued jobs)
420
+ # Can be an Integer or Lambda/Proc that is invoked in the context of the job
418
421
  perform_limit: 1,
419
422
 
420
423
  # Note: Under heavy load, the total number of jobs may exceed the
@@ -444,10 +447,11 @@ job.good_job_concurrency_key #=> "Unique-Alice"
444
447
 
445
448
  #### How concurrency controls work
446
449
 
447
- GoodJob's concurrency control strategy for `perform_limit` is "optimistic retry with an incremental backoff". The [code is readable](https://github.com/bensheldon/good_job/blob/main/lib/good_job/active_job_extensions/concurrency.rb).
450
+ GoodJob's concurrency control strategy for `perform_limit` is "optimistic retry with an incremental backoff". The [code is readable](https://github.com/bensheldon/good_job/blob/main/lib/good_job/active_job_extensions/concurrency.rb).
448
451
 
449
- - "Optimistic" meaning that the implementation's performance trade-off assumes that collisions are atypical (e.g. two users enqueue the same job at the same time) rather than regular (e.g. the system enqueues thousands of colliding jobs at the same time).
452
+ - "Optimistic" meaning that the implementation's performance trade-off assumes that collisions are atypical (e.g. two users enqueue the same job at the same time) rather than regular (e.g. the system enqueues thousands of colliding jobs at the same time). Depending on your concurrency requirements, you may also want to manage concurrency through the number of GoodJob threads and processes that are performing a given queue.
450
453
  - "Retry with an incremental backoff" means that when `perform_limit` is exceeded, the job will raise a `GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError` which is caught by a `retry_on` handler which re-schedules the job to execute in the near future with an incremental backoff.
454
+ - First-in-first-out job execution order is not preserved when a job is retried with incremental back-off.
451
455
 
452
456
  ### Cron-style repeating/recurring jobs
453
457
 
@@ -31,11 +31,17 @@ module GoodJob
31
31
  next(block.call) if CurrentThread.active_job_id == job.job_id
32
32
 
33
33
  enqueue_limit = job.class.good_job_concurrency_config[:enqueue_limit]
34
- total_limit = job.class.good_job_concurrency_config[:total_limit]
34
+ enqueue_limit = instance_exec(&enqueue_limit) if enqueue_limit.respond_to?(:call)
35
+ enqueue_limit = nil unless enqueue_limit.present? && (0...Float::INFINITY).cover?(enqueue_limit)
35
36
 
36
- has_limit = (enqueue_limit.present? && (0...Float::INFINITY).cover?(enqueue_limit)) ||
37
- (total_limit.present? && (0...Float::INFINITY).cover?(total_limit))
38
- next(block.call) unless has_limit
37
+ unless enqueue_limit
38
+ total_limit = job.class.good_job_concurrency_config[:total_limit]
39
+ total_limit = instance_exec(&total_limit) if total_limit.respond_to?(:call)
40
+ total_limit = nil unless total_limit.present? && (0...Float::INFINITY).cover?(total_limit)
41
+ end
42
+
43
+ limit = enqueue_limit || total_limit
44
+ next(block.call) unless limit
39
45
 
40
46
  # Only generate the concurrency key on the initial enqueue in case it is dynamic
41
47
  job.good_job_concurrency_key ||= job._good_job_concurrency_key
@@ -50,7 +56,7 @@ module GoodJob
50
56
  end
51
57
 
52
58
  # The job has not yet been enqueued, so check if adding it will go over the limit
53
- block.call unless enqueue_concurrency + 1 > (enqueue_limit || total_limit)
59
+ block.call unless (enqueue_concurrency + 1) > limit
54
60
  end
55
61
  end
56
62
 
@@ -64,11 +70,18 @@ module GoodJob
64
70
  # Don't attempt to enforce concurrency limits with other queue adapters.
65
71
  next unless job.class.queue_adapter.is_a?(GoodJob::Adapter)
66
72
 
67
- perform_limit = job.class.good_job_concurrency_config[:perform_limit] ||
68
- job.class.good_job_concurrency_config[:total_limit]
73
+ perform_limit = job.class.good_job_concurrency_config[:perform_limit]
74
+ perform_limit = instance_exec(&perform_limit) if perform_limit.respond_to?(:call)
75
+ perform_limit = nil unless perform_limit.present? && (0...Float::INFINITY).cover?(perform_limit)
76
+
77
+ unless perform_limit
78
+ total_limit = job.class.good_job_concurrency_config[:total_limit]
79
+ total_limit = instance_exec(&total_limit) if total_limit.respond_to?(:call)
80
+ total_limit = nil unless total_limit.present? && (0...Float::INFINITY).cover?(total_limit)
81
+ end
69
82
 
70
- has_limit = perform_limit.present? && (0...Float::INFINITY).cover?(perform_limit)
71
- next unless has_limit
83
+ limit = perform_limit || total_limit
84
+ next unless limit
72
85
 
73
86
  key = job.good_job_concurrency_key
74
87
  next if key.blank?
@@ -79,7 +92,7 @@ module GoodJob
79
92
  end
80
93
 
81
94
  GoodJob::Execution.advisory_lock_key(key, function: "pg_advisory_lock") do
82
- allowed_active_job_ids = GoodJob::Execution.unfinished.where(concurrency_key: key).advisory_locked.order(Arel.sql("COALESCE(performed_at, scheduled_at, created_at) ASC")).limit(perform_limit).pluck(:active_job_id)
95
+ allowed_active_job_ids = GoodJob::Execution.unfinished.where(concurrency_key: key).advisory_locked.order(Arel.sql("COALESCE(performed_at, scheduled_at, created_at) ASC")).limit(limit).pluck(:active_job_id)
83
96
  # The current job has already been locked and will appear in the previous query
84
97
  raise GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError unless allowed_active_job_ids.include? job.job_id
85
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '3.4.2'
4
+ VERSION = '3.4.3'
5
5
  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: 3.4.2
4
+ version: 3.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-13 00:00:00.000000000 Z
11
+ date: 2022-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -290,20 +290,6 @@ dependencies:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
- - !ruby/object:Gem::Dependency
294
- name: sigdump
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - ">="
298
- - !ruby/object:Gem::Version
299
- version: '0'
300
- type: :development
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - ">="
305
- - !ruby/object:Gem::Version
306
- version: '0'
307
293
  - !ruby/object:Gem::Dependency
308
294
  name: yard
309
295
  requirement: !ruby/object:Gem::Requirement