good_job 3.30.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +22 -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/filters/good_job/base_filter.rb +1 -1
- data/app/helpers/good_job/application_helper.rb +1 -0
- data/app/models/concerns/good_job/error_events.rb +2 -2
- data/app/models/concerns/good_job/filterable.rb +1 -1
- data/app/models/good_job/base_execution.rb +544 -50
- data/app/models/good_job/cron_entry.rb +0 -2
- data/app/models/good_job/discrete_execution.rb +1 -26
- data/app/models/good_job/execution.rb +3 -609
- 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 +5 -0
- data/config/locales/de.yml +10 -2
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +10 -2
- data/config/locales/fr.yml +10 -2
- data/config/locales/it.yml +10 -2
- data/config/locales/ja.yml +10 -2
- data/config/locales/ko.yml +10 -2
- data/config/locales/nl.yml +10 -2
- data/config/locales/pt-BR.yml +10 -2
- data/config/locales/ru.yml +10 -2
- data/config/locales/tr.yml +10 -2
- data/config/locales/uk.yml +10 -2
- data/config/routes.rb +2 -0
- 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 +22 -21
- metadata +18 -30
- 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 -17
- data/lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb +0 -37
- 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,6 +194,14 @@ ja:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
197
|
+
performance:
|
198
|
+
index:
|
199
|
+
average_duration: 平均所要時間
|
200
|
+
executions: 処刑
|
201
|
+
job_class: 職種
|
202
|
+
maximum_duration: 最大持続時間
|
203
|
+
minimum_duration: 最小期間
|
204
|
+
title: パフォーマンス
|
199
205
|
processes:
|
200
206
|
index:
|
201
207
|
cron_enabled: Cron が有効になっている
|
@@ -225,12 +231,14 @@ ja:
|
|
225
231
|
jobs: ジョブ
|
226
232
|
live_poll: リアルタイム更新
|
227
233
|
name: "GoodJob 👍"
|
234
|
+
performance: パフォーマンス
|
228
235
|
processes: プロセス
|
229
236
|
theme:
|
230
237
|
auto: 自動
|
231
238
|
dark: 暗い
|
232
239
|
light: ライト
|
233
240
|
theme: テーマ
|
241
|
+
pending_migrations: GoodJobに保留中のデータベースマイグレーションがあります。
|
234
242
|
secondary_navbar:
|
235
243
|
inspiration: 覚えておいてください、あなたも良い仕事をしています!
|
236
244
|
last_updated: 最終更新
|
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,6 +194,14 @@ ko:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
197
|
+
performance:
|
198
|
+
index:
|
199
|
+
average_duration: 평균 지속 시간
|
200
|
+
executions: 처형
|
201
|
+
job_class: 직업군
|
202
|
+
maximum_duration: 최대 기간
|
203
|
+
minimum_duration: 최소 기간
|
204
|
+
title: 성능
|
199
205
|
processes:
|
200
206
|
index:
|
201
207
|
cron_enabled: Cron이 활성화되어 있음
|
@@ -225,12 +231,14 @@ ko:
|
|
225
231
|
jobs: 작업
|
226
232
|
live_poll: 실시간 업데이트
|
227
233
|
name: "GoodJob 👍"
|
234
|
+
performance: 성능
|
228
235
|
processes: 프로세스
|
229
236
|
theme:
|
230
237
|
auto: 자동
|
231
238
|
dark: 어두운
|
232
239
|
light: 밝은
|
233
240
|
theme: 테마
|
241
|
+
pending_migrations: GoodJob에 보류 중인 데이터베이스 마이그레이션 작업이 있습니다.
|
234
242
|
secondary_navbar:
|
235
243
|
inspiration: 기억하세요, 당신도 좋은 일을 하고 있습니다!
|
236
244
|
last_updated: 최종 업데이트
|
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,6 +194,14 @@ nl:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
197
|
+
performance:
|
198
|
+
index:
|
199
|
+
average_duration: Gemiddelde duur
|
200
|
+
executions: Executies
|
201
|
+
job_class: Functie klasse
|
202
|
+
maximum_duration: Maximale duur
|
203
|
+
minimum_duration: Minimale duur
|
204
|
+
title: Prestatie
|
199
205
|
processes:
|
200
206
|
index:
|
201
207
|
cron_enabled: Cron ingeschakeld
|
@@ -225,12 +231,14 @@ nl:
|
|
225
231
|
jobs: Taken
|
226
232
|
live_poll: Live Poll
|
227
233
|
name: "GoodJob 👍"
|
234
|
+
performance: Prestatie
|
228
235
|
processes: Processen
|
229
236
|
theme:
|
230
237
|
auto: Auto
|
231
238
|
dark: Donker
|
232
239
|
light: Licht
|
233
240
|
theme: Thema
|
241
|
+
pending_migrations: GoodJob heeft databasemigraties in behandeling.
|
234
242
|
secondary_navbar:
|
235
243
|
inspiration: 'Onthoud: jij levert ook goed werk!'
|
236
244
|
last_updated: Laatst bijgewerkt
|
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,6 +194,14 @@ pt-BR:
|
|
196
194
|
thousand: K
|
197
195
|
trillion: T
|
198
196
|
unit: ''
|
197
|
+
performance:
|
198
|
+
index:
|
199
|
+
average_duration: Duração média
|
200
|
+
executions: Execuções
|
201
|
+
job_class: Classe de trabalho
|
202
|
+
maximum_duration: Duração máxima
|
203
|
+
minimum_duration: Duração mínima
|
204
|
+
title: Desempenho
|
199
205
|
processes:
|
200
206
|
index:
|
201
207
|
cron_enabled: Agendamento ativado
|
@@ -225,12 +231,14 @@ pt-BR:
|
|
225
231
|
jobs: Tarefas
|
226
232
|
live_poll: Acompanhamento ao Vivo
|
227
233
|
name: "GoodJob 👍"
|
234
|
+
performance: Desempenho
|
228
235
|
processes: Processos
|
229
236
|
theme:
|
230
237
|
auto: Automático
|
231
238
|
dark: Escuro
|
232
239
|
light: Claro
|
233
240
|
theme: Tema
|
241
|
+
pending_migrations: O GoodJob tem migrações pendentes no banco de dados.
|
234
242
|
secondary_navbar:
|
235
243
|
inspiration: Lembre-se, você também está fazendo uma Boa Tarefa!
|
236
244
|
last_updated: Última atualização
|
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,6 +220,14 @@ ru:
|
|
222
220
|
thousand: К
|
223
221
|
trillion: Т
|
224
222
|
unit: ''
|
223
|
+
performance:
|
224
|
+
index:
|
225
|
+
average_duration: Средняя продолжительность
|
226
|
+
executions: Казни
|
227
|
+
job_class: Класс работы
|
228
|
+
maximum_duration: Максимальная продолжительность
|
229
|
+
minimum_duration: Минимальная продолжительность
|
230
|
+
title: Производительность
|
225
231
|
processes:
|
226
232
|
index:
|
227
233
|
cron_enabled: Cron включен
|
@@ -251,12 +257,14 @@ ru:
|
|
251
257
|
jobs: Задания
|
252
258
|
live_poll: Обновления в реальном времени
|
253
259
|
name: "GoodJob 👍"
|
260
|
+
performance: Производительность
|
254
261
|
processes: Процессы
|
255
262
|
theme:
|
256
263
|
auto: Авто
|
257
264
|
dark: Темный
|
258
265
|
light: Светлая
|
259
266
|
theme: Тема офрмдления
|
267
|
+
pending_migrations: У GoodJob есть ожидающие миграции базы данных.
|
260
268
|
secondary_navbar:
|
261
269
|
inspiration: Благодаря вам Good Job становится лучше! Спасибо!
|
262
270
|
last_updated: Последнее обновление
|
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,6 +194,14 @@ tr:
|
|
196
194
|
thousand: Bin
|
197
195
|
trillion: Trilyon
|
198
196
|
unit: ''
|
197
|
+
performance:
|
198
|
+
index:
|
199
|
+
average_duration: Ortalama süre
|
200
|
+
executions: İnfazlar
|
201
|
+
job_class: İş sınıfı
|
202
|
+
maximum_duration: Maksimum süre
|
203
|
+
minimum_duration: Minimum süre
|
204
|
+
title: Verim
|
199
205
|
processes:
|
200
206
|
index:
|
201
207
|
cron_enabled: Cron etkin
|
@@ -225,12 +231,14 @@ tr:
|
|
225
231
|
jobs: İşler
|
226
232
|
live_poll: Anlık Güncelleme
|
227
233
|
name: "GoodJob 👍"
|
234
|
+
performance: Verim
|
228
235
|
processes: Süreçler
|
229
236
|
theme:
|
230
237
|
auto: Oto
|
231
238
|
dark: Karanlık
|
232
239
|
light: Işık
|
233
240
|
theme: Tema
|
241
|
+
pending_migrations: GoodJob'ın bekleyen veritabanı güncellemeleri bulunuyor.
|
234
242
|
secondary_navbar:
|
235
243
|
inspiration: Unutmayın, siz de iyi bir iş yapıyorsunuz!
|
236
244
|
last_updated: Son güncelleme
|
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,6 +220,14 @@ uk:
|
|
222
220
|
thousand: Тис
|
223
221
|
trillion: Трлн
|
224
222
|
unit: ''
|
223
|
+
performance:
|
224
|
+
index:
|
225
|
+
average_duration: Середня тривалість
|
226
|
+
executions: Страти
|
227
|
+
job_class: Клас роботи
|
228
|
+
maximum_duration: Максимальна тривалість
|
229
|
+
minimum_duration: Мінімальна тривалість
|
230
|
+
title: Продуктивність
|
225
231
|
processes:
|
226
232
|
index:
|
227
233
|
cron_enabled: Cron увімкнено
|
@@ -251,12 +257,14 @@ uk:
|
|
251
257
|
jobs: Задачі
|
252
258
|
live_poll: Живе Опитування
|
253
259
|
name: "GoodJob 👍"
|
260
|
+
performance: Продуктивність
|
254
261
|
processes: Процеси
|
255
262
|
theme:
|
256
263
|
auto: Авто
|
257
264
|
dark: Темний
|
258
265
|
light: світло
|
259
266
|
theme: Тема
|
267
|
+
pending_migrations: GoodJob має невиконані міграції бази даних.
|
260
268
|
secondary_navbar:
|
261
269
|
inspiration: Пам'ятайте, ви теж робите хорошу роботу!
|
262
270
|
last_updated: Останнє оновлення
|
data/config/routes.rb
CHANGED
@@ -31,6 +31,8 @@ GoodJob::Engine.routes.draw do
|
|
31
31
|
|
32
32
|
resources :processes, only: %i[index]
|
33
33
|
|
34
|
+
resources :performance, only: %i[index]
|
35
|
+
|
34
36
|
scope :frontend, controller: :frontends do
|
35
37
|
get "modules/:name", action: :module, as: :frontend_module, constraints: { format: 'js' }
|
36
38
|
get "static/:name", action: :static, as: :frontend_static, constraints: { format: %w[css 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
|
@@ -18,14 +18,6 @@ module GoodJob
|
|
18
18
|
# Responds to the +$0.good_job+ notification.
|
19
19
|
# @param event [ActiveSupport::Notifications::Event]
|
20
20
|
# @return [void]
|
21
|
-
def create(event)
|
22
|
-
# FIXME: This method does not match any good_job notifications.
|
23
|
-
execution = event.payload[:execution]
|
24
|
-
|
25
|
-
debug do
|
26
|
-
"GoodJob created job resource with id #{execution.id}"
|
27
|
-
end
|
28
|
-
end
|
29
21
|
|
30
22
|
# @!macro notification_responder
|
31
23
|
def finished_timer_task(event)
|
@@ -110,12 +102,12 @@ module GoodJob
|
|
110
102
|
|
111
103
|
# @!macro notification_responder
|
112
104
|
def perform_job(event)
|
113
|
-
|
105
|
+
job = event.payload[:job]
|
114
106
|
process_id = event.payload[:process_id]
|
115
107
|
thread_name = event.payload[:thread_name]
|
116
108
|
|
117
109
|
info(tags: [process_id, thread_name]) do
|
118
|
-
"Executed GoodJob #{
|
110
|
+
"Executed GoodJob #{job.id}"
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|