good_job 3.99.0 → 4.0.1
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 +21 -0
- data/app/charts/good_job/scheduled_by_queue_chart.rb +2 -2
- data/app/controllers/good_job/cron_entries_controller.rb +0 -8
- data/app/controllers/good_job/metrics_controller.rb +1 -1
- data/app/controllers/good_job/performance_controller.rb +19 -0
- data/app/models/concerns/good_job/filterable.rb +1 -1
- data/app/models/good_job/base_execution.rb +104 -201
- data/app/models/good_job/cron_entry.rb +0 -2
- data/app/models/good_job/discrete_execution.rb +1 -31
- data/app/models/good_job/execution.rb +3 -7
- data/app/models/good_job/job.rb +37 -116
- data/app/models/good_job/process.rb +7 -20
- data/app/views/good_job/batches/index.html.erb +11 -15
- data/app/views/good_job/jobs/_executions.erb +1 -1
- data/app/views/good_job/jobs/_table.erb +1 -1
- data/app/views/good_job/jobs/show.html.erb +1 -8
- data/app/views/good_job/performance/index.html.erb +43 -0
- data/app/views/good_job/shared/_navbar.erb +2 -2
- data/config/locales/de.yml +4 -7
- data/config/locales/en.yml +4 -7
- data/config/locales/es.yml +4 -7
- data/config/locales/fr.yml +4 -7
- data/config/locales/it.yml +4 -7
- data/config/locales/ja.yml +4 -7
- data/config/locales/ko.yml +4 -7
- data/config/locales/nl.yml +4 -7
- data/config/locales/pt-BR.yml +4 -7
- data/config/locales/ru.yml +4 -7
- data/config/locales/tr.yml +4 -7
- data/config/locales/uk.yml +4 -7
- data/config/routes.rb +1 -1
- data/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb +65 -3
- data/lib/good_job/active_job_extensions/batches.rb +1 -1
- data/lib/good_job/active_job_extensions/concurrency.rb +10 -10
- data/lib/good_job/adapter.rb +13 -24
- data/lib/good_job/configuration.rb +5 -1
- data/lib/good_job/current_thread.rb +6 -6
- data/lib/good_job/job_performer.rb +2 -2
- data/lib/good_job/log_subscriber.rb +2 -10
- data/lib/good_job/notifier.rb +3 -3
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +16 -21
- metadata +18 -32
- data/app/controllers/good_job/performances_controller.rb +0 -23
- data/app/views/good_job/performances/show.html.erb +0 -50
- data/lib/generators/good_job/templates/update/migrations/02_create_good_job_settings.rb.erb +0 -20
- data/lib/generators/good_job/templates/update/migrations/03_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb.erb +0 -19
- data/lib/generators/good_job/templates/update/migrations/04_create_good_job_batches.rb.erb +0 -35
- data/lib/generators/good_job/templates/update/migrations/05_create_good_job_executions.rb.erb +0 -33
- data/lib/generators/good_job/templates/update/migrations/06_create_good_jobs_error_event.rb.erb +0 -16
- data/lib/generators/good_job/templates/update/migrations/07_recreate_good_job_cron_indexes_with_conditional.rb.erb +0 -45
- data/lib/generators/good_job/templates/update/migrations/08_create_good_job_labels.rb.erb +0 -15
- data/lib/generators/good_job/templates/update/migrations/09_create_good_job_labels_index.rb.erb +0 -22
- data/lib/generators/good_job/templates/update/migrations/10_remove_good_job_active_id_index.rb.erb +0 -21
- data/lib/generators/good_job/templates/update/migrations/11_create_index_good_job_jobs_for_candidate_lookup.rb.erb +0 -19
- data/lib/generators/good_job/templates/update/migrations/12_create_good_job_execution_error_backtrace.rb.erb +0 -15
- data/lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb +0 -18
- data/lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb +0 -38
- data/lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb +0 -15
data/config/locales/ja.yml
CHANGED
@@ -11,7 +11,6 @@ ja:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: より古いバッチ
|
14
|
-
pending_migrations: GoodJobに保留中のデータベースマイグレーションがあります。
|
15
14
|
title: バッチ
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ ja:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: cronスケジュールが見つかりませんでした。
|
50
49
|
title: cronスケジュール
|
51
|
-
pending_migrations: GoodJobの保留中のデータベースマイグレーションが必要です。
|
52
50
|
show:
|
53
51
|
cron_entry_key: cronエントリキー
|
54
52
|
datetime:
|
@@ -196,8 +194,8 @@ ja:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
199
|
-
|
200
|
-
|
197
|
+
performance:
|
198
|
+
index:
|
201
199
|
average_duration: 平均所要時間
|
202
200
|
executions: 処刑
|
203
201
|
job_class: 職種
|
@@ -233,13 +231,14 @@ ja:
|
|
233
231
|
jobs: ジョブ
|
234
232
|
live_poll: リアルタイム更新
|
235
233
|
name: "GoodJob 👍"
|
236
|
-
|
234
|
+
performance: パフォーマンス
|
237
235
|
processes: プロセス
|
238
236
|
theme:
|
239
237
|
auto: 自動
|
240
238
|
dark: 暗い
|
241
239
|
light: ライト
|
242
240
|
theme: テーマ
|
241
|
+
pending_migrations: GoodJobに保留中のデータベースマイグレーションがあります。
|
243
242
|
secondary_navbar:
|
244
243
|
inspiration: 覚えておいてください、あなたも良い仕事をしています!
|
245
244
|
last_updated: 最終更新
|
@@ -250,5 +249,3 @@ ja:
|
|
250
249
|
running: 実行中
|
251
250
|
scheduled: スケジュール待ち
|
252
251
|
succeeded: 成功済み
|
253
|
-
shared:
|
254
|
-
needs_migration: GoodJob 移行を実行してください。
|
data/config/locales/ko.yml
CHANGED
@@ -11,7 +11,6 @@ ko:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: 더 오래된 배치
|
14
|
-
pending_migrations: GoodJob에 보류 중인 데이터베이스 마이그레이션 작업이 있습니다.
|
15
14
|
title: 배치
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ ko:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: cron 스케줄을 찾을 수 없습니다.
|
50
49
|
title: cron 스케줄
|
51
|
-
pending_migrations: 보류 중인 GoodJob 데이터베이스 마이그레이션이 필요합니다.
|
52
50
|
show:
|
53
51
|
cron_entry_key: cron 엔트리 키
|
54
52
|
datetime:
|
@@ -196,8 +194,8 @@ ko:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
199
|
-
|
200
|
-
|
197
|
+
performance:
|
198
|
+
index:
|
201
199
|
average_duration: 평균 지속 시간
|
202
200
|
executions: 처형
|
203
201
|
job_class: 직업군
|
@@ -233,13 +231,14 @@ ko:
|
|
233
231
|
jobs: 작업
|
234
232
|
live_poll: 실시간 업데이트
|
235
233
|
name: "GoodJob 👍"
|
236
|
-
|
234
|
+
performance: 성능
|
237
235
|
processes: 프로세스
|
238
236
|
theme:
|
239
237
|
auto: 자동
|
240
238
|
dark: 어두운
|
241
239
|
light: 밝은
|
242
240
|
theme: 테마
|
241
|
+
pending_migrations: GoodJob에 보류 중인 데이터베이스 마이그레이션 작업이 있습니다.
|
243
242
|
secondary_navbar:
|
244
243
|
inspiration: 기억하세요, 당신도 좋은 일을 하고 있습니다!
|
245
244
|
last_updated: 최종 업데이트
|
@@ -250,5 +249,3 @@ ko:
|
|
250
249
|
running: 실행 중
|
251
250
|
scheduled: 예정됨
|
252
251
|
succeeded: 성공함
|
253
|
-
shared:
|
254
|
-
needs_migration: GoodJob 마이그레이션을 실행하세요.
|
data/config/locales/nl.yml
CHANGED
@@ -11,7 +11,6 @@ nl:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: Oudere partijen
|
14
|
-
pending_migrations: GoodJob heeft databasemigraties in behandeling.
|
15
14
|
title: Partijen
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ nl:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: Geen cron-schema's gevonden.
|
50
49
|
title: Cron-schema's
|
51
|
-
pending_migrations: Vereist GoodJob-databasemigratie in afwachting.
|
52
50
|
show:
|
53
51
|
cron_entry_key: Cron-invoersleutel
|
54
52
|
datetime:
|
@@ -196,8 +194,8 @@ nl:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
199
|
-
|
200
|
-
|
197
|
+
performance:
|
198
|
+
index:
|
201
199
|
average_duration: Gemiddelde duur
|
202
200
|
executions: Executies
|
203
201
|
job_class: Functie klasse
|
@@ -233,13 +231,14 @@ nl:
|
|
233
231
|
jobs: Taken
|
234
232
|
live_poll: Live Poll
|
235
233
|
name: "GoodJob 👍"
|
236
|
-
|
234
|
+
performance: Prestatie
|
237
235
|
processes: Processen
|
238
236
|
theme:
|
239
237
|
auto: Auto
|
240
238
|
dark: Donker
|
241
239
|
light: Licht
|
242
240
|
theme: Thema
|
241
|
+
pending_migrations: GoodJob heeft databasemigraties in behandeling.
|
243
242
|
secondary_navbar:
|
244
243
|
inspiration: 'Onthoud: jij levert ook goed werk!'
|
245
244
|
last_updated: Laatst bijgewerkt
|
@@ -250,5 +249,3 @@ nl:
|
|
250
249
|
running: Rennen
|
251
250
|
scheduled: Gepland
|
252
251
|
succeeded: Geslaagd
|
253
|
-
shared:
|
254
|
-
needs_migration: Voer GoodJob-migraties uit.
|
data/config/locales/pt-BR.yml
CHANGED
@@ -11,7 +11,6 @@ pt-BR:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: Lotes antigos
|
14
|
-
pending_migrations: O GoodJob tem migrações pendentes no banco de dados.
|
15
14
|
title: Lotes
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ pt-BR:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: Nenhuma tarefa programada encontrada.
|
50
49
|
title: Tarefas Programadas
|
51
|
-
pending_migrations: Requer migração pendente do GoodJob no banco de dados.
|
52
50
|
show:
|
53
51
|
cron_entry_key: Chave da Tarefa Programada
|
54
52
|
datetime:
|
@@ -196,8 +194,8 @@ pt-BR:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
199
|
-
|
200
|
-
|
197
|
+
performance:
|
198
|
+
index:
|
201
199
|
average_duration: Duração média
|
202
200
|
executions: Execuções
|
203
201
|
job_class: Classe de trabalho
|
@@ -233,13 +231,14 @@ pt-BR:
|
|
233
231
|
jobs: Tarefas
|
234
232
|
live_poll: Acompanhamento ao Vivo
|
235
233
|
name: "GoodJob 👍"
|
236
|
-
|
234
|
+
performance: Desempenho
|
237
235
|
processes: Processos
|
238
236
|
theme:
|
239
237
|
auto: Automático
|
240
238
|
dark: Escuro
|
241
239
|
light: Claro
|
242
240
|
theme: Tema
|
241
|
+
pending_migrations: O GoodJob tem migrações pendentes no banco de dados.
|
243
242
|
secondary_navbar:
|
244
243
|
inspiration: Lembre-se, você também está fazendo uma Boa Tarefa!
|
245
244
|
last_updated: Última atualização
|
@@ -250,5 +249,3 @@ pt-BR:
|
|
250
249
|
running: Em execução
|
251
250
|
scheduled: Agendado
|
252
251
|
succeeded: Concluído com sucesso
|
253
|
-
shared:
|
254
|
-
needs_migration: Execute migrações GoodJob.
|
data/config/locales/ru.yml
CHANGED
@@ -11,7 +11,6 @@ ru:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: Старые группы заданий
|
14
|
-
pending_migrations: У GoodJob есть ожидающие миграции базы данных.
|
15
14
|
title: Группы заданий
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ ru:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: Расписания cron не найдены.
|
50
49
|
title: Расписания cron
|
51
|
-
pending_migrations: У GoodJob есть ожидающие миграции базы данных.
|
52
50
|
show:
|
53
51
|
cron_entry_key: Ключ cron-задания
|
54
52
|
datetime:
|
@@ -222,8 +220,8 @@ ru:
|
|
222
220
|
thousand: К
|
223
221
|
trillion: Т
|
224
222
|
unit: ''
|
225
|
-
|
226
|
-
|
223
|
+
performance:
|
224
|
+
index:
|
227
225
|
average_duration: Средняя продолжительность
|
228
226
|
executions: Казни
|
229
227
|
job_class: Класс работы
|
@@ -259,13 +257,14 @@ ru:
|
|
259
257
|
jobs: Задания
|
260
258
|
live_poll: Обновления в реальном времени
|
261
259
|
name: "GoodJob 👍"
|
262
|
-
|
260
|
+
performance: Производительность
|
263
261
|
processes: Процессы
|
264
262
|
theme:
|
265
263
|
auto: Авто
|
266
264
|
dark: Темный
|
267
265
|
light: Светлая
|
268
266
|
theme: Тема офрмдления
|
267
|
+
pending_migrations: У GoodJob есть ожидающие миграции базы данных.
|
269
268
|
secondary_navbar:
|
270
269
|
inspiration: Благодаря вам Good Job становится лучше! Спасибо!
|
271
270
|
last_updated: Последнее обновление
|
@@ -276,5 +275,3 @@ ru:
|
|
276
275
|
running: Исполняется
|
277
276
|
scheduled: Запланировано
|
278
277
|
succeeded: Успешно
|
279
|
-
shared:
|
280
|
-
needs_migration: Пожалуйста, запустите миграцию GoodJob.
|
data/config/locales/tr.yml
CHANGED
@@ -11,7 +11,6 @@ tr:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: Daha eski toplu işlemler
|
14
|
-
pending_migrations: GoodJob'ın bekleyen veritabanı güncellemeleri bulunuyor.
|
15
14
|
title: Toplu İşlemler
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ tr:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: Planlanmış Cron bulunamadı.
|
50
49
|
title: Cron Planları
|
51
|
-
pending_migrations: Bekleyen GoodJob veritabanı güncellemesi var.
|
52
50
|
show:
|
53
51
|
cron_entry_key: Cron Giriş Anahtarı
|
54
52
|
datetime:
|
@@ -196,8 +194,8 @@ tr:
|
|
196
194
|
thousand: Bin
|
197
195
|
trillion: Trilyon
|
198
196
|
unit: ''
|
199
|
-
|
200
|
-
|
197
|
+
performance:
|
198
|
+
index:
|
201
199
|
average_duration: Ortalama süre
|
202
200
|
executions: İnfazlar
|
203
201
|
job_class: İş sınıfı
|
@@ -233,13 +231,14 @@ tr:
|
|
233
231
|
jobs: İşler
|
234
232
|
live_poll: Anlık Güncelleme
|
235
233
|
name: "GoodJob 👍"
|
236
|
-
|
234
|
+
performance: Verim
|
237
235
|
processes: Süreçler
|
238
236
|
theme:
|
239
237
|
auto: Oto
|
240
238
|
dark: Karanlık
|
241
239
|
light: Işık
|
242
240
|
theme: Tema
|
241
|
+
pending_migrations: GoodJob'ın bekleyen veritabanı güncellemeleri bulunuyor.
|
243
242
|
secondary_navbar:
|
244
243
|
inspiration: Unutmayın, siz de iyi bir iş yapıyorsunuz!
|
245
244
|
last_updated: Son güncelleme
|
@@ -250,5 +249,3 @@ tr:
|
|
250
249
|
running: Çalışıyor
|
251
250
|
scheduled: Planlandı
|
252
251
|
succeeded: Başarılı
|
253
|
-
shared:
|
254
|
-
needs_migration: Lütfen GoodJob geçişlerini çalıştırın.
|
data/config/locales/uk.yml
CHANGED
@@ -11,7 +11,6 @@ uk:
|
|
11
11
|
batches:
|
12
12
|
index:
|
13
13
|
older_batches: Старі пакети
|
14
|
-
pending_migrations: GoodJob має невиконані міграції бази даних.
|
15
14
|
title: Пакети
|
16
15
|
jobs:
|
17
16
|
actions:
|
@@ -48,7 +47,6 @@ uk:
|
|
48
47
|
index:
|
49
48
|
no_cron_schedules_found: Cron-розклади не знайдені.
|
50
49
|
title: Cron-розклади
|
51
|
-
pending_migrations: Вимагає невиконаних міграцій бази даних GoodJob.
|
52
50
|
show:
|
53
51
|
cron_entry_key: Ключ cron-запису
|
54
52
|
datetime:
|
@@ -222,8 +220,8 @@ uk:
|
|
222
220
|
thousand: Тис
|
223
221
|
trillion: Трлн
|
224
222
|
unit: ''
|
225
|
-
|
226
|
-
|
223
|
+
performance:
|
224
|
+
index:
|
227
225
|
average_duration: Середня тривалість
|
228
226
|
executions: Страти
|
229
227
|
job_class: Клас роботи
|
@@ -259,13 +257,14 @@ uk:
|
|
259
257
|
jobs: Задачі
|
260
258
|
live_poll: Живе Опитування
|
261
259
|
name: "GoodJob 👍"
|
262
|
-
|
260
|
+
performance: Продуктивність
|
263
261
|
processes: Процеси
|
264
262
|
theme:
|
265
263
|
auto: Авто
|
266
264
|
dark: Темний
|
267
265
|
light: світло
|
268
266
|
theme: Тема
|
267
|
+
pending_migrations: GoodJob має невиконані міграції бази даних.
|
269
268
|
secondary_navbar:
|
270
269
|
inspiration: Пам'ятайте, ви теж робите хорошу роботу!
|
271
270
|
last_updated: Останнє оновлення
|
@@ -276,5 +275,3 @@ uk:
|
|
276
275
|
running: Виконується
|
277
276
|
scheduled: Заплановано
|
278
277
|
succeeded: Успішно виконано
|
279
|
-
shared:
|
280
|
-
needs_migration: Запустіть міграції GoodJob.
|
data/config/routes.rb
CHANGED
@@ -31,7 +31,7 @@ GoodJob::Engine.routes.draw do
|
|
31
31
|
|
32
32
|
resources :processes, only: %i[index]
|
33
33
|
|
34
|
-
|
34
|
+
resources :performance, only: %i[index]
|
35
35
|
|
36
36
|
scope :frontend, controller: :frontends do
|
37
37
|
get "modules/:name", action: :module, as: :frontend_module, constraints: { format: 'js' }
|
@@ -21,20 +21,82 @@ class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %>
|
|
21
21
|
t.text :cron_key
|
22
22
|
t.uuid :retried_good_job_id
|
23
23
|
t.datetime :cron_at
|
24
|
+
|
25
|
+
t.uuid :batch_id
|
26
|
+
t.uuid :batch_callback_id
|
27
|
+
|
28
|
+
t.boolean :is_discrete
|
29
|
+
t.integer :executions_count
|
30
|
+
t.text :job_class
|
31
|
+
t.integer :error_event, limit: 2
|
32
|
+
t.text :labels, array: true
|
33
|
+
t.uuid :locked_by_id
|
34
|
+
t.datetime :locked_at
|
35
|
+
end
|
36
|
+
|
37
|
+
create_table :good_job_batches, id: :uuid do |t|
|
38
|
+
t.timestamps
|
39
|
+
t.text :description
|
40
|
+
t.jsonb :serialized_properties
|
41
|
+
t.text :on_finish
|
42
|
+
t.text :on_success
|
43
|
+
t.text :on_discard
|
44
|
+
t.text :callback_queue_name
|
45
|
+
t.integer :callback_priority
|
46
|
+
t.datetime :enqueued_at
|
47
|
+
t.datetime :discarded_at
|
48
|
+
t.datetime :finished_at
|
49
|
+
end
|
50
|
+
|
51
|
+
create_table :good_job_executions, id: :uuid do |t|
|
52
|
+
t.timestamps
|
53
|
+
|
54
|
+
t.uuid :active_job_id, null: false
|
55
|
+
t.text :job_class
|
56
|
+
t.text :queue_name
|
57
|
+
t.jsonb :serialized_params
|
58
|
+
t.datetime :scheduled_at
|
59
|
+
t.datetime :finished_at
|
60
|
+
t.text :error
|
61
|
+
t.integer :error_event, limit: 2
|
62
|
+
t.text :error_backtrace, array: true
|
63
|
+
t.uuid :process_id
|
64
|
+
t.interval :duration
|
24
65
|
end
|
25
66
|
|
26
67
|
create_table :good_job_processes, id: :uuid do |t|
|
27
68
|
t.timestamps
|
28
69
|
t.jsonb :state
|
70
|
+
t.integer :lock_type, limit: 2
|
71
|
+
end
|
72
|
+
|
73
|
+
create_table :good_job_settings, id: :uuid do |t|
|
74
|
+
t.timestamps
|
75
|
+
t.text :key
|
76
|
+
t.jsonb :value
|
77
|
+
t.index :key, unique: true
|
29
78
|
end
|
30
79
|
|
31
80
|
add_index :good_jobs, :scheduled_at, where: "(finished_at IS NULL)", name: :index_good_jobs_on_scheduled_at
|
32
81
|
add_index :good_jobs, [:queue_name, :scheduled_at], where: "(finished_at IS NULL)", name: :index_good_jobs_on_queue_name_and_scheduled_at
|
33
82
|
add_index :good_jobs, [:active_job_id, :created_at], name: :index_good_jobs_on_active_job_id_and_created_at
|
34
83
|
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", name: :index_good_jobs_on_concurrency_key_when_unfinished
|
35
|
-
add_index :good_jobs, [:cron_key, :created_at], name: :
|
36
|
-
add_index :good_jobs, [:cron_key, :cron_at],
|
37
|
-
add_index :good_jobs, [:active_job_id], name: :index_good_jobs_on_active_job_id
|
84
|
+
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)", name: :index_good_jobs_on_cron_key_and_created_at_cond
|
85
|
+
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true, name: :index_good_jobs_on_cron_key_and_cron_at_cond
|
38
86
|
add_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at
|
87
|
+
add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },
|
88
|
+
where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished
|
89
|
+
add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },
|
90
|
+
where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup
|
91
|
+
add_index :good_jobs, [:batch_id], where: "batch_id IS NOT NULL"
|
92
|
+
add_index :good_jobs, [:batch_callback_id], where: "batch_callback_id IS NOT NULL"
|
93
|
+
add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)", name: :index_good_jobs_on_labels
|
94
|
+
|
95
|
+
add_index :good_job_executions, [:active_job_id, :created_at], name: :index_good_job_executions_on_active_job_id_and_created_at
|
96
|
+
add_index :good_jobs, [:priority, :scheduled_at], order: { priority: "ASC NULLS LAST", scheduled_at: :asc },
|
97
|
+
where: "finished_at IS NULL AND locked_by_id IS NULL", name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked
|
98
|
+
add_index :good_jobs, :locked_by_id,
|
99
|
+
where: "locked_by_id IS NOT NULL", name: "index_good_jobs_on_locked_by_id"
|
100
|
+
add_index :good_job_executions, [:process_id, :created_at], name: :index_good_job_executions_on_process_id_and_created_at
|
39
101
|
end
|
40
102
|
end
|
@@ -12,7 +12,7 @@ module GoodJob
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def batch
|
15
|
-
@_batch ||= CurrentThread.
|
15
|
+
@_batch ||= CurrentThread.job&.batch&.to_batch if CurrentThread.job.present? && CurrentThread.job.active_job_id == job_id
|
16
16
|
end
|
17
17
|
alias batch? batch
|
18
18
|
end
|
@@ -66,7 +66,7 @@ module GoodJob
|
|
66
66
|
|
67
67
|
perform_throttle = job.class.good_job_concurrency_config[:perform_throttle]
|
68
68
|
perform_throttle = instance_exec(&perform_throttle) if perform_throttle.respond_to?(:call)
|
69
|
-
perform_throttle = nil unless
|
69
|
+
perform_throttle = nil unless perform_throttle.present? && perform_throttle.is_a?(Array) && perform_throttle.size == 2
|
70
70
|
|
71
71
|
limit = perform_limit || total_limit
|
72
72
|
throttle = perform_throttle
|
@@ -75,17 +75,17 @@ module GoodJob
|
|
75
75
|
key = job.good_job_concurrency_key
|
76
76
|
next if key.blank?
|
77
77
|
|
78
|
-
if CurrentThread.
|
78
|
+
if CurrentThread.job.blank? || CurrentThread.job.active_job_id != job_id
|
79
79
|
logger.debug("Ignoring concurrency limits because the job is executed with `perform_now`.")
|
80
80
|
next
|
81
81
|
end
|
82
82
|
|
83
|
-
GoodJob::
|
83
|
+
GoodJob::Job.advisory_lock_key(key, function: "pg_advisory_lock") do
|
84
84
|
if limit
|
85
|
-
allowed_active_job_ids = GoodJob::
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
allowed_active_job_ids = GoodJob::Job.unfinished.where(concurrency_key: key)
|
86
|
+
.advisory_locked
|
87
|
+
.order(Arel.sql("COALESCE(performed_at, scheduled_at, created_at) ASC"))
|
88
|
+
.limit(limit).pluck(:active_job_id)
|
89
89
|
# The current job has already been locked and will appear in the previous query
|
90
90
|
raise GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError unless allowed_active_job_ids.include?(job.job_id)
|
91
91
|
end
|
@@ -172,12 +172,12 @@ module GoodJob
|
|
172
172
|
throttle = enqueue_throttle
|
173
173
|
return on_enqueue&.call unless limit || throttle
|
174
174
|
|
175
|
-
GoodJob::
|
175
|
+
GoodJob::Job.advisory_lock_key(key, function: "pg_advisory_lock") do
|
176
176
|
if limit
|
177
177
|
enqueue_concurrency = if enqueue_limit
|
178
|
-
GoodJob::
|
178
|
+
GoodJob::Job.where(concurrency_key: key).unfinished.advisory_unlocked.count
|
179
179
|
else
|
180
|
-
GoodJob::
|
180
|
+
GoodJob::Job.where(concurrency_key: key).unfinished.count
|
181
181
|
end
|
182
182
|
|
183
183
|
# The job has not yet been enqueued, so check if adding it will go over the limit
|
data/lib/good_job/adapter.rb
CHANGED
@@ -37,7 +37,7 @@ module GoodJob
|
|
37
37
|
# Enqueues the ActiveJob job to be performed.
|
38
38
|
# For use by Rails; you should generally not call this directly.
|
39
39
|
# @param active_job [ActiveJob::Base] the job to be enqueued from +#perform_later+
|
40
|
-
# @return [GoodJob::
|
40
|
+
# @return [GoodJob::Job]
|
41
41
|
def enqueue(active_job)
|
42
42
|
enqueue_at(active_job, nil)
|
43
43
|
end
|
@@ -58,28 +58,17 @@ module GoodJob
|
|
58
58
|
Rails.application.executor.wrap do
|
59
59
|
current_time = Time.current
|
60
60
|
executions = active_jobs.map do |active_job|
|
61
|
-
GoodJob::
|
62
|
-
if
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
execution.created_at = current_time
|
68
|
-
execution.updated_at = current_time
|
61
|
+
GoodJob::Job.build_for_enqueue(active_job).tap do |job|
|
62
|
+
job.scheduled_at = current_time if job.scheduled_at == job.created_at
|
63
|
+
job.created_at = current_time
|
64
|
+
job.updated_at = current_time
|
69
65
|
end
|
70
66
|
end
|
71
67
|
|
72
68
|
inline_executions = []
|
73
|
-
GoodJob::
|
74
|
-
execution_attributes = executions.map
|
75
|
-
|
76
|
-
execution.attributes
|
77
|
-
else
|
78
|
-
execution.attributes.except('error_event')
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
results = GoodJob::Execution.insert_all(execution_attributes, returning: %w[id active_job_id]) # rubocop:disable Rails/SkipsModelValidations
|
69
|
+
GoodJob::Job.transaction(requires_new: true, joinable: false) do
|
70
|
+
execution_attributes = executions.map(&:attributes)
|
71
|
+
results = GoodJob::Job.insert_all(execution_attributes, returning: %w[id active_job_id]) # rubocop:disable Rails/SkipsModelValidations
|
83
72
|
|
84
73
|
job_id_to_provider_job_id = results.each_with_object({}) { |result, hash| hash[result['active_job_id']] = result['id'] }
|
85
74
|
active_jobs.each do |active_job|
|
@@ -146,7 +135,7 @@ module GoodJob
|
|
146
135
|
# For use by Rails; you should generally not call this directly.
|
147
136
|
# @param active_job [ActiveJob::Base] the job to be enqueued from +#perform_later+
|
148
137
|
# @param timestamp [Integer, nil] the epoch time to perform the job
|
149
|
-
# @return [GoodJob::
|
138
|
+
# @return [GoodJob::Job]
|
150
139
|
def enqueue_at(active_job, timestamp)
|
151
140
|
scheduled_at = timestamp ? Time.zone.at(timestamp) : nil
|
152
141
|
|
@@ -156,15 +145,15 @@ module GoodJob
|
|
156
145
|
|
157
146
|
Rails.application.executor.wrap do
|
158
147
|
will_execute_inline = execute_inline? && (scheduled_at.nil? || scheduled_at <= Time.current)
|
159
|
-
will_retry_inline = will_execute_inline && CurrentThread.
|
148
|
+
will_retry_inline = will_execute_inline && CurrentThread.job&.active_job_id == active_job.job_id && !CurrentThread.retry_now
|
160
149
|
|
161
150
|
if will_retry_inline
|
162
|
-
execution = GoodJob::
|
151
|
+
execution = GoodJob::Job.enqueue(
|
163
152
|
active_job,
|
164
153
|
scheduled_at: scheduled_at
|
165
154
|
)
|
166
155
|
elsif will_execute_inline
|
167
|
-
execution = GoodJob::
|
156
|
+
execution = GoodJob::Job.enqueue(
|
168
157
|
active_job,
|
169
158
|
scheduled_at: scheduled_at,
|
170
159
|
create_with_advisory_lock: true
|
@@ -186,7 +175,7 @@ module GoodJob
|
|
186
175
|
end
|
187
176
|
raise result.unhandled_error if result.unhandled_error
|
188
177
|
else
|
189
|
-
execution = GoodJob::
|
178
|
+
execution = GoodJob::Job.enqueue(
|
190
179
|
active_job,
|
191
180
|
scheduled_at: scheduled_at
|
192
181
|
)
|
@@ -35,6 +35,8 @@ module GoodJob
|
|
35
35
|
DEFAULT_DASHBOARD_LIVE_POLL_ENABLED = true
|
36
36
|
# Default enqueue_after_transaction_commit
|
37
37
|
DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT = false
|
38
|
+
# Default smaller_number_is_higher_priority
|
39
|
+
DEFAULT_SMALLER_NUMBER_IS_HIGHER_PRIORITY = true
|
38
40
|
|
39
41
|
def self.validate_execution_mode(execution_mode)
|
40
42
|
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)
|
@@ -378,7 +380,9 @@ module GoodJob
|
|
378
380
|
end
|
379
381
|
|
380
382
|
def smaller_number_is_higher_priority
|
381
|
-
rails_config[:smaller_number_is_higher_priority]
|
383
|
+
return rails_config[:smaller_number_is_higher_priority] unless rails_config[:smaller_number_is_higher_priority].nil?
|
384
|
+
|
385
|
+
DEFAULT_SMALLER_NUMBER_IS_HIGHER_PRIORITY
|
382
386
|
end
|
383
387
|
|
384
388
|
def dashboard_default_locale
|
@@ -13,7 +13,7 @@ module GoodJob
|
|
13
13
|
error_on_discard
|
14
14
|
error_on_retry
|
15
15
|
error_on_retry_stopped
|
16
|
-
|
16
|
+
job
|
17
17
|
execution_interrupted
|
18
18
|
execution_retried
|
19
19
|
retry_now
|
@@ -49,11 +49,11 @@ module GoodJob
|
|
49
49
|
# @return [Exception, nil]
|
50
50
|
thread_mattr_accessor :error_on_retry_stopped
|
51
51
|
|
52
|
-
# @!attribute [rw]
|
52
|
+
# @!attribute [rw] jobs
|
53
53
|
# @!scope class
|
54
54
|
# Execution
|
55
|
-
# @return [GoodJob::
|
56
|
-
thread_mattr_accessor :
|
55
|
+
# @return [GoodJob::Job, nil]
|
56
|
+
thread_mattr_accessor :job
|
57
57
|
|
58
58
|
# @!attribute [rw] execution_interrupted
|
59
59
|
# @!scope class
|
@@ -90,9 +90,9 @@ module GoodJob
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
# @return [String] UUID of the currently executing GoodJob::
|
93
|
+
# @return [String] UUID of the currently executing GoodJob::Job
|
94
94
|
def self.active_job_id
|
95
|
-
|
95
|
+
job&.active_job_id
|
96
96
|
end
|
97
97
|
|
98
98
|
# @return [Integer] Current process ID
|
@@ -108,11 +108,11 @@ module GoodJob
|
|
108
108
|
attr_reader :queue_string
|
109
109
|
|
110
110
|
def job_query
|
111
|
-
@_job_query ||= GoodJob::
|
111
|
+
@_job_query ||= GoodJob::Job.queue_string(queue_string)
|
112
112
|
end
|
113
113
|
|
114
114
|
def parsed_queues
|
115
|
-
@_parsed_queues ||= GoodJob::
|
115
|
+
@_parsed_queues ||= GoodJob::Job.queue_parser(queue_string)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|