good_job 3.27.2 → 3.27.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f1caf94daea82b4e273aeaa01d2a44def87934a36275fbe5ca007a27bfceb4d
4
- data.tar.gz: ad46d59cc2166d6386a17a3d0924f27f81c16e1670121b7f252ec9515da4b011
3
+ metadata.gz: fa73a0d9ffc1feb2548c525af767537d79a8b6fdf4e03092c4963d91041eb73a
4
+ data.tar.gz: 41365ce2085788ff587d85a96d6bf1568fb5861ea025e98c87990ae65485ffc8
5
5
  SHA512:
6
- metadata.gz: 0c2be38cdbbfc7bb63f65451efc85ac51519f1ebabe7f9324ff5a652344b2e06fb75e93a0f0db0cda5038cf562ea793cf5eab6022cc219a304cab5be42b8dd0c
7
- data.tar.gz: fe5e5d39d0f02a071d8906b155bac1b9467167565544595c38932870e85aff88569b5c9194ea20cf8ea403c134b3a8833e5075e3c8c0bda51982ddea31e6c406
6
+ metadata.gz: a300b98ed92353715dff14d18940f0e9fa2896e1cda56428c026e62b162e3f7a2f5a07eba2a9501af2d0c1f4fa51f3c225a4ecc103f73e8eac862ec343902e6e
7
+ data.tar.gz: 25241155b1d5e375a903cbeec98e88ecaaca2fc46b1134c92ed400fbf2b024a637744db072fe42fb9af486e7ce43cec5262c6c31adceb2f948af3aacb7cc9584
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.27.4](https://github.com/bensheldon/good_job/tree/v3.27.4) (2024-04-04)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.27.3...v3.27.4)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fix status tabs for Spanish translation [\#1307](https://github.com/bensheldon/good_job/pull/1307) ([bensheldon](https://github.com/bensheldon))
10
+
11
+ **Closed issues:**
12
+
13
+ - Adapter to implement `enqueue_after_transaction_commit` [\#1310](https://github.com/bensheldon/good_job/issues/1310)
14
+ - PG::SyntaxError: ERROR from timestamp [\#1305](https://github.com/bensheldon/good_job/issues/1305)
15
+ - Spanish translation while on the dashboard displays hashes instead of the job status name [\#1304](https://github.com/bensheldon/good_job/issues/1304)
16
+ - Exception raised during asset precompilation when no `config/database.yml` [\#1302](https://github.com/bensheldon/good_job/issues/1302)
17
+ - Good job is running with standalone action cable server [\#1299](https://github.com/bensheldon/good_job/issues/1299)
18
+ - Growing memory usage [\#1276](https://github.com/bensheldon/good_job/issues/1276)
19
+
20
+ **Merged pull requests:**
21
+
22
+ - Implement enqueue\_after\_transaction\_commit? [\#1311](https://github.com/bensheldon/good_job/pull/1311) ([luizkowalski](https://github.com/luizkowalski))
23
+ - Fix localization formatting of `confirm_force_discard` [\#1309](https://github.com/bensheldon/good_job/pull/1309) ([bensheldon](https://github.com/bensheldon))
24
+
25
+ ## [v3.27.3](https://github.com/bensheldon/good_job/tree/v3.27.3) (2024-03-29)
26
+
27
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.27.2...v3.27.3)
28
+
29
+ **Merged pull requests:**
30
+
31
+ - Revert "Start async adapters `after_initialize` instead of once Active Job and Active Record are loaded and Rails initialized?" [\#1303](https://github.com/bensheldon/good_job/pull/1303) ([bensheldon](https://github.com/bensheldon))
32
+
3
33
  ## [v3.27.2](https://github.com/bensheldon/good_job/tree/v3.27.2) (2024-03-27)
4
34
 
5
35
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.27.1...v3.27.2)
@@ -111,9 +111,7 @@ de:
111
111
  actions:
112
112
  confirm_destroy: Sind Sie sicher, dass Sie den Job zerstören wollen?
113
113
  confirm_discard: Sind Sie sicher, dass Sie den Job verwerfen wollen?
114
- confirm_force_discard: 'Sind Sie sicher, dass Sie das Verwerfen dieses Jobs erzwingen möchten? Der Job wird als verworfen markiert, aber der laufende Job wird nicht gestoppt – er wird jedoch bei Fehlern nicht erneut versucht.
115
-
116
- '
114
+ confirm_force_discard: Sind Sie sicher, dass Sie das Verwerfen dieses Jobs erzwingen möchten? Der Job wird als verworfen markiert, aber der laufende Job wird nicht gestoppt – er wird jedoch bei Fehlern nicht erneut versucht.
117
115
  confirm_reschedule: Möchten Sie den Auftrag wirklich verschieben?
118
116
  confirm_retry: Möchten Sie den Job wirklich wiederholen?
119
117
  destroy: Arbeit vernichten
@@ -111,9 +111,7 @@ en:
111
111
  actions:
112
112
  confirm_destroy: Are you sure you want to destroy the job?
113
113
  confirm_discard: Are you usure you want to discard the job?
114
- confirm_force_discard: 'Are you sure you want to force discard this job? The job will be marked as discarded but the running job will not be stopped - it will, however, not be retried on failures.
115
-
116
- '
114
+ confirm_force_discard: Are you sure you want to force discard this job? The job will be marked as discarded but the running job will not be stopped - it will, however, not be retried on failures.
117
115
  confirm_reschedule: Are you sure you want to reschedule the job?
118
116
  confirm_retry: Are you sure you want to retry the job?
119
117
  destroy: Destroy job
@@ -233,19 +233,9 @@ es:
233
233
  inspiration: "¡Recuerda, también tú estás haciendo un buen trabajo!"
234
234
  last_updated: Última actualización
235
235
  status:
236
- discarded:
237
- one: Descartada
238
- other: Descartadas
239
- queued:
240
- one: Encolada
241
- other: Encoladas
242
- retried:
243
- one: Reintentada
244
- other: Reintentadas
245
- running: Corriendo
246
- scheduled:
247
- one: Programada
248
- other: Programadas
249
- succeeded:
250
- one: Exitosa
251
- other: Exitosas
236
+ discarded: Descartado
237
+ queued: Encolado
238
+ retried: Reintentado
239
+ running: Ejecutando
240
+ scheduled: Programado
241
+ succeeded: Exitoso
@@ -33,9 +33,9 @@ fr:
33
33
  no_batches_found: Aucun lot trouvé.
34
34
  cron_entries:
35
35
  actions:
36
- confirm_disable: Voulez-vous vraiment désactiver cette entrée cron?
37
- confirm_enable: Voulez-vous vraiment activer cette entrée cron?
38
- confirm_enqueue: Voulez-vous vraiment mettre en file d'attente cette entrée cron?
36
+ confirm_disable: Voulez-vous vraiment désactiver cette entrée cron ?
37
+ confirm_enable: Voulez-vous vraiment activer cette entrée cron ?
38
+ confirm_enqueue: Voulez-vous vraiment mettre en file d'attente cette entrée cron ?
39
39
  disable: Désactiver l'entrée cron
40
40
  enable: Activer l'entrée cron
41
41
  enqueue: Mettre en file d'attente l'entrée cron maintenant
@@ -111,9 +111,7 @@ fr:
111
111
  actions:
112
112
  confirm_destroy: Voulez-vous vraiment détruire le job ?
113
113
  confirm_discard: Voulez-vous vraiment mettre au rebut le job ?
114
- confirm_force_discard: 'Êtes-vous sûr de vouloir forcer l''abandon de cette tâche ? Le travail sera marqué comme abandonné mais le travail en cours d''exécution ne sera pas arrêté - il ne sera cependant pas réessayé en cas d''échec.
115
-
116
- '
114
+ confirm_force_discard: Êtes-vous sûr de vouloir forcer l'abandon du travail? Le travail sera marqué comme abandonné mais le travail en cours ne sera pas arrêté - cependant, il ne sera pas réessayé en cas d'échec.
117
115
  confirm_reschedule: Voulez-vous vraiment replanifier le job ?
118
116
  confirm_retry: Voulez-vous vraiment réessayer le job ?
119
117
  destroy: Détruire le job
@@ -146,7 +144,7 @@ fr:
146
144
  one: Appliquer à ce job
147
145
  other: Appliquer aux %{count} jobs
148
146
  confirm_destroy_all: Voulez-vous vraiment détruire les jobs sélectionnés ?
149
- confirm_discard_all: Voulez-vous vraiment mettre au rebut les jobs sélectionnés?
147
+ confirm_discard_all: Voulez-vous vraiment mettre au rebut les jobs sélectionnés ?
150
148
  confirm_reschedule_all: Voulez-vous vraiment replanifier les jobs sélectionnées ?
151
149
  confirm_retry_all: Voulez-vous vraiment réessayer les jobs sélectionnées ?
152
150
  destroy_all: Tout détruire
@@ -111,9 +111,7 @@ it:
111
111
  actions:
112
112
  confirm_destroy: Sei sicuro di voler eliminare il job?
113
113
  confirm_discard: Sei sicuro di voler scartare il job?
114
- confirm_force_discard: 'Sei sicuro di voler forzare lo scarto di questo job? Il job verrà contrassegnato come scartato ma il job in esecuzione non verrà interrotto - tuttavia, non verrà riprovato in caso di fallimento.
115
-
116
- '
114
+ confirm_force_discard: Sei sicuro di voler forzare lo scarto di questo job? Il job verrà contrassegnato come scartato ma il job in esecuzione non verrà interrotto - tuttavia, non verrà riprovato in caso di fallimento.
117
115
  confirm_reschedule: Sei sicuro di voler riprogrammare il job?
118
116
  confirm_retry: Sei sicuro di voler riprovare il job?
119
117
  destroy: Elimina job
@@ -111,9 +111,7 @@ ja:
111
111
  actions:
112
112
  confirm_destroy: ジョブを削除してもよろしいですか?
113
113
  confirm_discard: ジョブを破棄してもよろしいですか?
114
- confirm_force_discard: 'このジョブを強制的に破棄してもよろしいですか?ジョブは破棄済みとしてマークされますが、実行中のジョブは停止されません。ただし、失敗した場合は再試行されません。
115
-
116
- '
114
+ confirm_force_discard: このジョブを強制的に破棄してもよろしいですか?ジョブは破棄済みとしてマークされますが、実行中のジョブは停止されません。ただし、失敗した場合は再試行されません。
117
115
  confirm_reschedule: ジョブを再スケジュールしてもよろしいですか?
118
116
  confirm_retry: ジョブを再試行してもよろしいですか?
119
117
  destroy: ジョブを削除
@@ -111,9 +111,7 @@ ko:
111
111
  actions:
112
112
  confirm_destroy: 해당 작업을 삭제하시겠습니까?
113
113
  confirm_discard: 해당 작업을 폐기하시겠습니까?
114
- confirm_force_discard: '이 작업을 강제로 폐기하시겠습니까? 작업은 폐기로 표시되지만, 실행 중인 작업은 중지되지 않습니다. 그러나 실패한 경우 재시도되지 않습니다.
115
-
116
- '
114
+ confirm_force_discard: 이 작업을 강제로 폐기하시겠습니까? 작업은 폐기로 표시되지만, 실행 중인 작업은 중지되지 않습니다. 그러나 실패한 경우 재시도되지 않습니다.
117
115
  confirm_reschedule: 해당 작업을 재예약하시겠습니까?
118
116
  confirm_retry: 해당 작업을 다시 시도하시겠습니까?
119
117
  destroy: 작업 삭제
@@ -111,9 +111,7 @@ nl:
111
111
  actions:
112
112
  confirm_destroy: Weet je zeker dat je de baan wilt vernietigen?
113
113
  confirm_discard: Wilt u de baan afwijzen?
114
- confirm_force_discard: 'Weet u zeker dat u deze taak geforceerd wilt weggooien? De taak wordt gemarkeerd als verwijderd, maar de lopende taak wordt niet gestopt. Bij fouten wordt deze echter niet opnieuw geprobeerd.
115
-
116
- '
114
+ confirm_force_discard: Weet u zeker dat u deze taak geforceerd wilt weggooien? De taak wordt gemarkeerd als verwijderd, maar de lopende taak wordt niet gestopt. Bij fouten wordt deze echter niet opnieuw geprobeerd.
117
115
  confirm_reschedule: Weet u zeker dat u de taak opnieuw wilt inplannen?
118
116
  confirm_retry: Weet u zeker dat u de taak opnieuw wilt proberen?
119
117
  destroy: Baan vernietigen
@@ -111,9 +111,7 @@ pt-BR:
111
111
  actions:
112
112
  confirm_destroy: Tem certeza de que deseja excluir a tarefa?
113
113
  confirm_discard: Tem certeza de que deseja descartar a tarefa?
114
- confirm_force_discard: 'Tem certeza de que deseja forçar o descarte desta tarefa? A tarefa será marcada como descartada, mas a tarefa em execução não será interrompida - no entanto, ela não será tentada novamente em falhas.
115
-
116
- '
114
+ confirm_force_discard: Tem certeza de que deseja forçar o descarte desta tarefa? A tarefa será marcada como descartada, mas a tarefa em execução não será interrompida - no entanto, ela não será tentada novamente em falhas.
117
115
  confirm_reschedule: Tem certeza de que deseja reagendar a tarefa?
118
116
  confirm_retry: Tem certeza de que deseja tentar novamente a tarefa?
119
117
  destroy: Excluir tarefa
@@ -111,9 +111,7 @@ tr:
111
111
  actions:
112
112
  confirm_destroy: Bu işi silmek istediğinizden emin misiniz?
113
113
  confirm_discard: Bu işi iptal etmek istediğinizden emin misiniz?
114
- confirm_force_discard: 'Bu işi zorla iptal etmek istediğinizden emin misiniz? İş atıldı olarak işaretlenecek ancak devam eden iş durdurulmayacak; ancak başarısızlık durumunda yeniden denenmeyecek.
115
-
116
- '
114
+ confirm_force_discard: Bu işi zorla iptal etmek istediğinizden emin misiniz? İş atıldı olarak işaretlenecek ancak devam eden iş durdurulmayacak; ancak başarısızlık durumunda yeniden denenmeyecek.
117
115
  confirm_reschedule: Bu işi yeniden planlamak istediğinizden emin misiniz?
118
116
  confirm_retry: Bu işi tekrar denemek istediğinizden emin misiniz?
119
117
  destroy: İşi Sil
@@ -135,9 +135,7 @@ uk:
135
135
  actions:
136
136
  confirm_destroy: Ви впевнені, що хочете видалити завдання?
137
137
  confirm_discard: Ви впевнені, що хочете відхилити завдання?
138
- confirm_force_discard: 'Ви впевнені, що хочете примусово скасувати цю роботу? Завдання буде позначено як відхилене, але виконуване завдання не буде зупинено – однак його не буде повторено у випадку помилок.
139
-
140
- '
138
+ confirm_force_discard: Ви впевнені, що хочете примусово скасувати цю роботу? Завдання буде позначено як відхилене, але виконуване завдання не буде зупинено – однак його не буде повторено у випадку помилок.
141
139
  confirm_reschedule: Ви впевнені, що хочете перепланувати завдання?
142
140
  confirm_retry: Ви впевнені, що хочете повторити завдання?
143
141
  destroy: Видалити завдання
@@ -30,7 +30,7 @@ module GoodJob
30
30
  GoodJob::Configuration.validate_execution_mode(@_execution_mode_override) if @_execution_mode_override
31
31
  @capsule = _capsule
32
32
 
33
- start_async if GoodJob._async_ready?
33
+ start_async if GoodJob.async_ready?
34
34
  self.class.instances << self
35
35
  end
36
36
 
@@ -42,6 +42,12 @@ module GoodJob
42
42
  enqueue_at(active_job, nil)
43
43
  end
44
44
 
45
+ # Defines if enqueueing this job from inside an Active Record transaction
46
+ # automatically defers the enqueue to after the transaction commit.
47
+ def enqueue_after_transaction_commit?
48
+ GoodJob.configuration.enqueue_after_transaction_commit
49
+ end
50
+
45
51
  # Enqueues multiple ActiveJob instances at once
46
52
  # @param active_jobs [Array<ActiveJob::Base>] jobs to be enqueued
47
53
  # @return [Integer] number of jobs that were successfully enqueued
data/lib/good_job/bulk.rb CHANGED
@@ -14,7 +14,7 @@ module GoodJob
14
14
 
15
15
  # Capture jobs to a buffer. Pass either a block, or specific Active Jobs to be buffered.
16
16
  # @param active_jobs [Array<ActiveJob::Base>] Active Jobs to be buffered.
17
- # @param queue_adapter Override the jobs implict queue adapter with an explicit one.
17
+ # @param queue_adapter Override the jobs implicit queue adapter with an explicit one.
18
18
  # @return [nil, Array<ActiveJob::Base>] The ActiveJob instances that have been buffered; nil if no active buffer
19
19
  def self.capture(active_jobs = nil, queue_adapter: nil, &block)
20
20
  raise(ArgumentError, "Use either the block form or the argument form, not both") if block && active_jobs
@@ -33,6 +33,8 @@ module GoodJob
33
33
  DEFAULT_DASHBOARD_DEFAULT_LOCALE = :en
34
34
  # Default Dashboard Live Poll button enabled
35
35
  DEFAULT_DASHBOARD_LIVE_POLL_ENABLED = true
36
+ # Default enqueue_after_transaction_commit
37
+ DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT = false
36
38
 
37
39
  def self.validate_execution_mode(execution_mode)
38
40
  raise ArgumentError, "GoodJob execution mode must be one of #{EXECUTION_MODES.join(', ')}. It was '#{execution_mode}' which is not valid." unless execution_mode.in?(EXECUTION_MODES)
@@ -389,6 +391,14 @@ module GoodJob
389
391
  DEFAULT_DASHBOARD_LIVE_POLL_ENABLED
390
392
  end
391
393
 
394
+ # Whether the Adapter should have Active Job enqueue jobs after the transaction has committed.
395
+ # @return [Boolean]
396
+ def enqueue_after_transaction_commit
397
+ return options[:enqueue_after_transaction_commit] unless options[:enqueue_after_transaction_commit].nil?
398
+
399
+ DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT
400
+ end
401
+
392
402
  # Whether running in a web server process.
393
403
  # @return [Boolean, nil]
394
404
  def in_webserver?
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoodJob # :nodoc:
4
+ # Extends GoodJob module to track Rails boot dependencies.
5
+ module Dependencies
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ mattr_accessor :_framework_ready, default: false
10
+ end
11
+
12
+ class_methods do
13
+ # Whether Rails framework has sufficiently initialized to enable Async execution.
14
+ def async_ready?
15
+ Rails.application.initialized? || _framework_ready
16
+ end
17
+
18
+ def _start_async_adapters
19
+ return unless async_ready?
20
+
21
+ ActiveJob::Base.queue_adapter # Ensure Active Job is initialized
22
+ GoodJob::Adapter.instances
23
+ .select(&:execute_async?)
24
+ .reject(&:async_started?)
25
+ .each(&:start_async)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -49,17 +49,22 @@ module GoodJob
49
49
  end
50
50
 
51
51
  initializer "good_job.start_async" do
52
+ # This hooks into the hookable places during Rails boot, which is unfortunately not Rails.application.initialized?
53
+ # If an Adapter is initialized during boot, we want to want to start async executors once the framework dependencies have loaded.
54
+ # When exactly that happens is out of our control because gems or application code may touch things earlier than expected.
55
+ # For example, as of Rails 6.1, if an ActiveRecord model is touched during boot, that triggers ActiveRecord to load,
56
+ # which touches DestroyAssociationAsyncJob, which loads ActiveJob, which may initialize a GoodJob::Adapter, all of which
57
+ # happens _before_ ActiveRecord finishes loading. GoodJob will deadlock if an async executor is started in the middle of
58
+ # ActiveRecord loading.
52
59
  config.after_initialize do
53
- GoodJob._async_ready = true
54
-
55
- # Ensure Active Record and Active Job are fully loaded
56
- ActiveRecord::Base # rubocop:disable Lint/Void
57
- ActiveJob::Base.queue_adapter
58
-
59
- GoodJob::Adapter.instances
60
- .select(&:execute_async?)
61
- .reject(&:async_started?)
62
- .each(&:start_async)
60
+ ActiveSupport.on_load(:active_record) do
61
+ ActiveSupport.on_load(:active_job) do
62
+ GoodJob._framework_ready = true
63
+ GoodJob._start_async_adapters
64
+ end
65
+ GoodJob._start_async_adapters
66
+ end
67
+ GoodJob._start_async_adapters
63
68
  end
64
69
  end
65
70
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '3.27.2'
5
+ VERSION = '3.27.4'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
data/lib/good_job.rb CHANGED
@@ -25,6 +25,7 @@ require_relative "good_job/configuration"
25
25
  require_relative "good_job/cron_manager"
26
26
  require_relative "good_job/current_thread"
27
27
  require_relative "good_job/daemon"
28
+ require_relative "good_job/dependencies"
28
29
  require_relative "good_job/job_performer"
29
30
  require_relative "good_job/job_performer/metrics"
30
31
  require_relative "good_job/log_subscriber"
@@ -45,6 +46,7 @@ require_relative "good_job/thread_status"
45
46
  #
46
47
  # +GoodJob+ is the top-level namespace and exposes configuration attributes.
47
48
  module GoodJob
49
+ include GoodJob::Dependencies
48
50
  include GoodJob::ThreadStatus
49
51
 
50
52
  # Default, null, blank value placeholder.
@@ -112,11 +114,6 @@ module GoodJob
112
114
  # @return [GoodJob::Capsule, nil]
113
115
  mattr_accessor :capsule, default: GoodJob::Capsule.new(configuration: configuration)
114
116
 
115
- mattr_accessor :_async_ready, default: false
116
- def self._async_ready?
117
- _async_ready
118
- end
119
-
120
117
  # Called with exception when a GoodJob thread raises an exception
121
118
  # @param exception [Exception] Exception that was raised
122
119
  # @return [void]
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.27.2
4
+ version: 3.27.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-27 00:00:00.000000000 Z
11
+ date: 2024-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -404,6 +404,7 @@ files:
404
404
  - lib/good_job/cron_manager.rb
405
405
  - lib/good_job/current_thread.rb
406
406
  - lib/good_job/daemon.rb
407
+ - lib/good_job/dependencies.rb
407
408
  - lib/good_job/engine.rb
408
409
  - lib/good_job/interrupt_error.rb
409
410
  - lib/good_job/job_performer.rb