pgbus 0.8.4 → 0.9.2

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/app/assets/javascripts/pgbus/stream_source_element.js +150 -5
  4. data/app/controllers/pgbus/batches_controller.rb +15 -0
  5. data/app/helpers/pgbus/application_helper.rb +12 -0
  6. data/app/views/layouts/pgbus/application.html.erb +2 -0
  7. data/app/views/pgbus/batches/_batches_table.html.erb +54 -0
  8. data/app/views/pgbus/batches/index.html.erb +8 -0
  9. data/app/views/pgbus/batches/show.html.erb +90 -0
  10. data/config/locales/da.yml +34 -0
  11. data/config/locales/de.yml +34 -0
  12. data/config/locales/en.yml +34 -0
  13. data/config/locales/es.yml +34 -0
  14. data/config/locales/fi.yml +34 -0
  15. data/config/locales/fr.yml +34 -0
  16. data/config/locales/it.yml +34 -0
  17. data/config/locales/ja.yml +34 -0
  18. data/config/locales/nb.yml +34 -0
  19. data/config/locales/nl.yml +34 -0
  20. data/config/locales/pt.yml +34 -0
  21. data/config/locales/sv.yml +34 -0
  22. data/config/routes.rb +1 -0
  23. data/lib/pgbus/client.rb +102 -4
  24. data/lib/pgbus/configuration.rb +84 -0
  25. data/lib/pgbus/execution_pools/async_pool.rb +44 -6
  26. data/lib/pgbus/process/supervisor.rb +2 -1
  27. data/lib/pgbus/process/worker.rb +38 -1
  28. data/lib/pgbus/serializer.rb +1 -1
  29. data/lib/pgbus/streams/coalescer.rb +88 -0
  30. data/lib/pgbus/streams/envelope.rb +20 -1
  31. data/lib/pgbus/streams/key.rb +35 -2
  32. data/lib/pgbus/streams/renderer.rb +67 -0
  33. data/lib/pgbus/streams.rb +150 -1
  34. data/lib/pgbus/version.rb +1 -1
  35. data/lib/pgbus/web/data_source.rb +96 -0
  36. data/lib/pgbus/web/stream_app.rb +8 -4
  37. data/lib/pgbus/web/streamer/connection.rb +15 -1
  38. data/lib/pgbus/web/streamer/falcon_connection.rb +9 -1
  39. data/lib/pgbus/web/streamer/heartbeat.rb +23 -1
  40. data/lib/pgbus/web/streamer/stream_event_dispatcher.rb +129 -14
  41. data/lib/pgbus.rb +11 -0
  42. data/lib/tasks/pgbus_queues.rake +54 -0
  43. metadata +10 -3
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  es:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Lotes de trabajos con seguimiento de progreso y callbacks
7
+ empty: No se encontraron lotes
8
+ headers:
9
+ batch_id: ID de lote
10
+ created: Creado
11
+ description: Descripción
12
+ jobs: Trabajos
13
+ progress: Progreso
14
+ status: Estado
15
+ title: Lotes
16
+ show:
17
+ back: Volver a lotes
18
+ batch_id: ID de lote
19
+ completed: Completados
20
+ created_at: Creado el
21
+ details: Detalles
22
+ discarded: Descartados
23
+ finished_at: Finalizado el
24
+ not_found: Lote no encontrado
25
+ on_discard: Al descartar
26
+ on_finish: Al finalizar
27
+ on_success: Al tener éxito
28
+ progress: Progreso
29
+ properties: Propiedades
30
+ remaining: Restantes
31
+ title: Lote
32
+ total_jobs: Total de trabajos
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: No hay procesos en ejecución
@@ -189,6 +218,10 @@ es:
189
218
  not_found: Evento no encontrado
190
219
  title: Evento %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Finalizado
223
+ pending: Pendiente
224
+ processing: Procesando
192
225
  bulk_select_all: Seleccionar todo
193
226
  bulk_select_row: Seleccionar %{id}
194
227
  bulk_selected: seleccionado
@@ -346,6 +379,7 @@ es:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Lotes
349
383
  dashboard: Panel de control
350
384
  dlq: DLQ
351
385
  events: Eventos
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  fi:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Tehtäväerät edistymisen seurannalla ja callback-kutsuilla
7
+ empty: Eriä ei löytynyt
8
+ headers:
9
+ batch_id: Erä-ID
10
+ created: Luotu
11
+ description: Kuvaus
12
+ jobs: Tehtävät
13
+ progress: Edistyminen
14
+ status: Tila
15
+ title: Erät
16
+ show:
17
+ back: Takaisin eriin
18
+ batch_id: Erä-ID
19
+ completed: Valmiit
20
+ created_at: Luotu
21
+ details: Tiedot
22
+ discarded: Hylätyt
23
+ finished_at: Valmistunut
24
+ not_found: Erää ei löytynyt
25
+ on_discard: Hylkäyksessä
26
+ on_finish: Valmistumisessa
27
+ on_success: Onnistumisessa
28
+ progress: Edistyminen
29
+ properties: Ominaisuudet
30
+ remaining: Jäljellä
31
+ title: Erä
32
+ total_jobs: Tehtäviä yhteensä
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Ei käynnissä olevia prosesseja
@@ -189,6 +218,10 @@ fi:
189
218
  not_found: Tapahtumaa ei löytynyt
190
219
  title: Tapahtuma %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Valmis
223
+ pending: Odottaa
224
+ processing: Käsittelyssä
192
225
  bulk_select_all: Valitse kaikki
193
226
  bulk_select_row: Valitse %{id}
194
227
  bulk_selected: valittu
@@ -346,6 +379,7 @@ fi:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Erät
349
383
  dashboard: Hallintapaneeli
350
384
  dlq: DLQ
351
385
  events: Tapahtumat
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  fr:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Lots de tâches avec suivi de progression et callbacks
7
+ empty: Aucun lot trouvé
8
+ headers:
9
+ batch_id: ID du lot
10
+ created: Créé
11
+ description: Description
12
+ jobs: Tâches
13
+ progress: Progression
14
+ status: Statut
15
+ title: Lots
16
+ show:
17
+ back: Retour aux lots
18
+ batch_id: ID du lot
19
+ completed: Terminées
20
+ created_at: Créé le
21
+ details: Détails
22
+ discarded: Rejetées
23
+ finished_at: Terminé le
24
+ not_found: Lot non trouvé
25
+ on_discard: Au rejet
26
+ on_finish: À la fin
27
+ on_success: Au succès
28
+ progress: Progression
29
+ properties: Propriétés
30
+ remaining: Restantes
31
+ title: Lot
32
+ total_jobs: Total des tâches
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Aucun processus en cours d'exécution
@@ -189,6 +218,10 @@ fr:
189
218
  not_found: Événement non trouvé
190
219
  title: Événement %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Terminé
223
+ pending: En attente
224
+ processing: En cours
192
225
  bulk_select_all: Tout sélectionner
193
226
  bulk_select_row: Sélectionner %{id}
194
227
  bulk_selected: sélectionné
@@ -346,6 +379,7 @@ fr:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Lots
349
383
  dashboard: Tableau de bord
350
384
  dlq: DLQ
351
385
  events: Événements
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  it:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Lotti di lavori con monitoraggio del progresso e callback
7
+ empty: Nessun lotto trovato
8
+ headers:
9
+ batch_id: ID lotto
10
+ created: Creato
11
+ description: Descrizione
12
+ jobs: Lavori
13
+ progress: Progresso
14
+ status: Stato
15
+ title: Lotti
16
+ show:
17
+ back: Torna ai lotti
18
+ batch_id: ID lotto
19
+ completed: Completati
20
+ created_at: Creato il
21
+ details: Dettagli
22
+ discarded: Scartati
23
+ finished_at: Terminato il
24
+ not_found: Lotto non trovato
25
+ on_discard: Allo scarto
26
+ on_finish: Al termine
27
+ on_success: Al successo
28
+ progress: Progresso
29
+ properties: Proprietà
30
+ remaining: Rimanenti
31
+ title: Lotto
32
+ total_jobs: Lavori totali
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Nessun processo in esecuzione
@@ -189,6 +218,10 @@ it:
189
218
  not_found: Evento non trovato
190
219
  title: Evento %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Terminato
223
+ pending: In sospeso
224
+ processing: In elaborazione
192
225
  bulk_select_all: Seleziona tutto
193
226
  bulk_select_row: Seleziona %{id}
194
227
  bulk_selected: selezionato
@@ -346,6 +379,7 @@ it:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Lotti
349
383
  dashboard: Cruscotto
350
384
  dlq: DLQ
351
385
  events: Eventi
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  ja:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: 進捗追跡とコールバック付きのジョブバッチ
7
+ empty: バッチが見つかりません
8
+ headers:
9
+ batch_id: バッチID
10
+ created: 作成日
11
+ description: 説明
12
+ jobs: ジョブ
13
+ progress: 進捗
14
+ status: ステータス
15
+ title: バッチ
16
+ show:
17
+ back: バッチに戻る
18
+ batch_id: バッチID
19
+ completed: 完了
20
+ created_at: 作成日時
21
+ details: 詳細
22
+ discarded: 破棄済み
23
+ finished_at: 完了日時
24
+ not_found: バッチが見つかりません
25
+ on_discard: 破棄時
26
+ on_finish: 完了時
27
+ on_success: 成功時
28
+ progress: 進捗
29
+ properties: プロパティ
30
+ remaining: 残り
31
+ title: バッチ
32
+ total_jobs: 合計ジョブ数
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: 実行中のプロセスはありません
@@ -189,6 +218,10 @@ ja:
189
218
  not_found: イベントが見つかりません
190
219
  title: イベント %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: 完了
223
+ pending: 保留中
224
+ processing: 処理中
192
225
  bulk_select_all: すべて選択
193
226
  bulk_select_row: "%{id}を選択"
194
227
  bulk_selected: 選択済み
@@ -346,6 +379,7 @@ ja:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: バッチ
349
383
  dashboard: ダッシュボード
350
384
  dlq: DLQ
351
385
  events: イベント
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  nb:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Jobbgrupper med fremdriftssporing og tilbakekall
7
+ empty: Ingen grupper funnet
8
+ headers:
9
+ batch_id: Gruppe-ID
10
+ created: Opprettet
11
+ description: Beskrivelse
12
+ jobs: Jobber
13
+ progress: Fremdrift
14
+ status: Status
15
+ title: Grupper
16
+ show:
17
+ back: Tilbake til grupper
18
+ batch_id: Gruppe-ID
19
+ completed: Fullført
20
+ created_at: Opprettet den
21
+ details: Detaljer
22
+ discarded: Forkastet
23
+ finished_at: Avsluttet den
24
+ not_found: Gruppe ikke funnet
25
+ on_discard: Ved forkastning
26
+ on_finish: Ved avslutning
27
+ on_success: Ved suksess
28
+ progress: Fremdrift
29
+ properties: Egenskaper
30
+ remaining: Gjenstående
31
+ title: Gruppe
32
+ total_jobs: Totalt antall jobber
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Ingen prosesser kjører
@@ -189,6 +218,10 @@ nb:
189
218
  not_found: Hendelse ikke funnet
190
219
  title: Hendelse %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Fullført
223
+ pending: Avventer
224
+ processing: Behandler
192
225
  bulk_select_all: Velg alle
193
226
  bulk_select_row: Velg %{id}
194
227
  bulk_selected: valgt
@@ -346,6 +379,7 @@ nb:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Grupper
349
383
  dashboard: Dashbord
350
384
  dlq: DLQ
351
385
  events: Hendelser
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  nl:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Taakgroepen met voortgangsregistratie en callbacks
7
+ empty: Geen groepen gevonden
8
+ headers:
9
+ batch_id: Groep-ID
10
+ created: Aangemaakt
11
+ description: Beschrijving
12
+ jobs: Taken
13
+ progress: Voortgang
14
+ status: Status
15
+ title: Groepen
16
+ show:
17
+ back: Terug naar groepen
18
+ batch_id: Groep-ID
19
+ completed: Voltooid
20
+ created_at: Aangemaakt op
21
+ details: Details
22
+ discarded: Verworpen
23
+ finished_at: Voltooid op
24
+ not_found: Groep niet gevonden
25
+ on_discard: Bij verwerping
26
+ on_finish: Bij voltooiing
27
+ on_success: Bij succes
28
+ progress: Voortgang
29
+ properties: Eigenschappen
30
+ remaining: Resterend
31
+ title: Groep
32
+ total_jobs: Totaal taken
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Geen processen actief
@@ -189,6 +218,10 @@ nl:
189
218
  not_found: Gebeurtenis niet gevonden
190
219
  title: Gebeurtenis %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Voltooid
223
+ pending: In afwachting
224
+ processing: Bezig
192
225
  bulk_select_all: Alles selecteren
193
226
  bulk_select_row: Selecteer %{id}
194
227
  bulk_selected: geselecteerd
@@ -346,6 +379,7 @@ nl:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Groepen
349
383
  dashboard: Dashboard
350
384
  dlq: DLQ
351
385
  events: Evenementen
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  pt:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Lotes de trabalhos com acompanhamento de progresso e callbacks
7
+ empty: Nenhum lote encontrado
8
+ headers:
9
+ batch_id: ID do lote
10
+ created: Criado
11
+ description: Descrição
12
+ jobs: Trabalhos
13
+ progress: Progresso
14
+ status: Status
15
+ title: Lotes
16
+ show:
17
+ back: Voltar para lotes
18
+ batch_id: ID do lote
19
+ completed: Concluídos
20
+ created_at: Criado em
21
+ details: Detalhes
22
+ discarded: Descartados
23
+ finished_at: Finalizado em
24
+ not_found: Lote não encontrado
25
+ on_discard: Ao descartar
26
+ on_finish: Ao finalizar
27
+ on_success: Ao ter sucesso
28
+ progress: Progresso
29
+ properties: Propriedades
30
+ remaining: Restantes
31
+ title: Lote
32
+ total_jobs: Total de trabalhos
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Nenhum processo em execução
@@ -189,6 +218,10 @@ pt:
189
218
  not_found: Evento não encontrado
190
219
  title: Evento %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Finalizado
223
+ pending: Pendente
224
+ processing: Processando
192
225
  bulk_select_all: Selecionar todos
193
226
  bulk_select_row: Selecionar %{id}
194
227
  bulk_selected: selecionado
@@ -346,6 +379,7 @@ pt:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Lotes
349
383
  dashboard: Painel
350
384
  dlq: DLQ
351
385
  events: Eventos
@@ -1,6 +1,35 @@
1
1
  ---
2
2
  sv:
3
3
  pgbus:
4
+ batches:
5
+ index:
6
+ description: Jobbgrupper med framstegsspårning och callbacks
7
+ empty: Inga grupper hittades
8
+ headers:
9
+ batch_id: Grupp-ID
10
+ created: Skapad
11
+ description: Beskrivning
12
+ jobs: Jobb
13
+ progress: Framsteg
14
+ status: Status
15
+ title: Grupper
16
+ show:
17
+ back: Tillbaka till grupper
18
+ batch_id: Grupp-ID
19
+ completed: Slutförda
20
+ created_at: Skapad den
21
+ details: Detaljer
22
+ discarded: Kasserade
23
+ finished_at: Avslutad den
24
+ not_found: Grupp hittades inte
25
+ on_discard: Vid kassering
26
+ on_finish: Vid avslut
27
+ on_success: Vid framgång
28
+ progress: Framsteg
29
+ properties: Egenskaper
30
+ remaining: Återstående
31
+ title: Grupp
32
+ total_jobs: Totalt antal jobb
4
33
  dashboard:
5
34
  processes_table:
6
35
  empty: Inga processer körs
@@ -189,6 +218,10 @@ sv:
189
218
  not_found: Händelse hittades inte
190
219
  title: Händelse %{event_id}
191
220
  helpers:
221
+ batch_status:
222
+ finished: Slutförd
223
+ pending: Väntande
224
+ processing: Bearbetas
192
225
  bulk_select_all: Markera alla
193
226
  bulk_select_row: Markera %{id}
194
227
  bulk_selected: valda
@@ -346,6 +379,7 @@ sv:
346
379
  layout:
347
380
  brand: Pgbus
348
381
  nav:
382
+ batches: Grupper
349
383
  dashboard: Instrumentpanel
350
384
  dlq: DLQ
351
385
  events: Händelser
data/config/routes.rb CHANGED
@@ -45,6 +45,7 @@ Pgbus::Engine.routes.draw do
45
45
  end
46
46
  end
47
47
 
48
+ resources :batches, only: %i[index show]
48
49
  resources :processes, only: [:index]
49
50
 
50
51
  resources :events, only: %i[index show] do
data/lib/pgbus/client.rb CHANGED
@@ -351,6 +351,87 @@ module Pgbus
351
351
  total
352
352
  end
353
353
 
354
+ # --- Grouped reads (PGMQ v1.11.0+) ---
355
+
356
+ def read_grouped(queue_name, qty:, vt: nil)
357
+ full_name = config.queue_name(queue_name)
358
+ Instrumentation.instrument("pgbus.client.read_grouped", queue: full_name, qty: qty) do
359
+ with_stale_connection_retry do
360
+ synchronized { @pgmq.read_grouped(full_name, vt: vt || config.visibility_timeout, qty: qty) }
361
+ end
362
+ end
363
+ end
364
+
365
+ def read_grouped_rr(queue_name, qty:, vt: nil)
366
+ full_name = config.queue_name(queue_name)
367
+ Instrumentation.instrument("pgbus.client.read_grouped_rr", queue: full_name, qty: qty) do
368
+ with_stale_connection_retry do
369
+ synchronized { @pgmq.read_grouped_rr(full_name, vt: vt || config.visibility_timeout, qty: qty) }
370
+ end
371
+ end
372
+ end
373
+
374
+ def read_grouped_head(queue_name, qty:, vt: nil)
375
+ full_name = config.queue_name(queue_name)
376
+ with_stale_connection_retry do
377
+ synchronized { @pgmq.read_grouped_head(full_name, vt: vt || config.visibility_timeout, qty: qty) }
378
+ end
379
+ end
380
+
381
+ # --- FIFO index management (PGMQ v1.11.0+) ---
382
+
383
+ def create_fifo_index(queue_name)
384
+ full_name = config.queue_name(queue_name)
385
+ with_stale_connection_retry do
386
+ synchronized { @pgmq.create_fifo_index(full_name) }
387
+ end
388
+ end
389
+
390
+ def create_fifo_indexes_all
391
+ with_stale_connection_retry do
392
+ synchronized { @pgmq.create_fifo_indexes_all }
393
+ end
394
+ end
395
+
396
+ # --- LISTEN/NOTIFY management (PGMQ v1.11.0+) ---
397
+
398
+ def wait_for_notify(queue_name, timeout: nil, &block)
399
+ full_name = config.queue_name(queue_name)
400
+ with_stale_connection_retry do
401
+ synchronized { @pgmq.wait_for_notify(full_name, timeout: timeout, &block) }
402
+ end
403
+ end
404
+
405
+ def update_notify_insert(queue_name, throttle_interval_ms:)
406
+ full_name = config.queue_name(queue_name)
407
+ with_stale_connection_retry do
408
+ synchronized { @pgmq.update_notify_insert(full_name, throttle_interval_ms: throttle_interval_ms) }
409
+ end
410
+ end
411
+
412
+ def list_notify_insert_throttles
413
+ with_stale_connection_retry do
414
+ synchronized { @pgmq.list_notify_insert_throttles }
415
+ end
416
+ end
417
+
418
+ # --- Archive partitioning (requires pg_partman extension) ---
419
+
420
+ def convert_archive_partitioned(queue_name, partition_interval: "10000", retention_interval: "100000",
421
+ leading_partition: 10)
422
+ full_name = config.queue_name(queue_name)
423
+ with_stale_connection_retry do
424
+ synchronized do
425
+ @pgmq.convert_archive_partitioned(
426
+ full_name,
427
+ partition_interval: partition_interval,
428
+ retention_interval: retention_interval,
429
+ leading_partition: leading_partition
430
+ )
431
+ end
432
+ end
433
+ end
434
+
354
435
  # Topic routing
355
436
  def bind_topic(pattern, queue_name)
356
437
  full_name = config.queue_name(queue_name)
@@ -503,6 +584,7 @@ module Pgbus
503
584
  @pgmq.create(full_name)
504
585
  tune_autovacuum(full_name)
505
586
  enable_notify_if_needed(full_name, NOTIFY_THROTTLE_MS)
587
+ create_fifo_index_if_needed(full_name)
506
588
  end
507
589
  true
508
590
  end
@@ -515,6 +597,12 @@ module Pgbus
515
597
  @pgmq.enable_notify_insert(full_name, throttle_interval_ms: throttle_ms)
516
598
  end
517
599
 
600
+ def create_fifo_index_if_needed(full_name)
601
+ return unless config.group_mode
602
+
603
+ @pgmq.create_fifo_index(full_name)
604
+ end
605
+
518
606
  # Check whether the NOTIFY trigger already exists on this queue with the
519
607
  # expected throttle interval. When it does, we can skip the destructive
520
608
  # DROP TRIGGER + CREATE TRIGGER cycle that causes deadlocks when multiple
@@ -544,11 +632,21 @@ module Pgbus
544
632
  false
545
633
  end
546
634
 
635
+ # Apply PGMQ-tuned autovacuum + storage parameters to a queue's tables.
636
+ #
637
+ # Delegates to pgmq-ruby's tune_autovacuum (v0.7+), which sets the same
638
+ # queue/archive parameters pgbus used to apply by hand — vacuum scale
639
+ # factor 0.01/0.05, cost_delay 2/5, analyze scale factor 0.05, and
640
+ # fillfactor 70 on the queue table — plus a vacuum_threshold floor of 50.
641
+ # It quotes/lowercases the table name and runs both ALTER TABLEs in one
642
+ # pooled checkout. Tuning is best-effort: a failure here never blocks a
643
+ # queue from being usable, so we log and move on.
644
+ #
645
+ # Pgbus::AutovacuumTuning is still the source for the migration generators
646
+ # (sql_for_all_queues, sql_for_high_churn_tables) which tune pgbus-owned
647
+ # metadata tables the gem doesn't know about.
547
648
  def tune_autovacuum(queue_name)
548
- with_raw_connection do |conn|
549
- conn.exec(AutovacuumTuning.sql_for_queue(queue_name))
550
- conn.exec(TableMaintenance.fillfactor_sql_for_queue(queue_name))
551
- end
649
+ @pgmq.tune_autovacuum(queue_name)
552
650
  rescue StandardError => e
553
651
  Pgbus.logger.debug { "[Pgbus::Client] Autovacuum tuning failed for #{queue_name}: #{e.message}" }
554
652
  end