pgbus 0.6.8 → 0.7.0
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/README.md +166 -0
- data/lib/generators/pgbus/add_failed_events_index_generator.rb +4 -11
- data/lib/generators/pgbus/add_job_locks_generator.rb +4 -11
- data/lib/generators/pgbus/add_job_stats_generator.rb +4 -11
- data/lib/generators/pgbus/add_job_stats_latency_generator.rb +4 -11
- data/lib/generators/pgbus/add_job_stats_queue_index_generator.rb +4 -11
- data/lib/generators/pgbus/add_outbox_generator.rb +4 -11
- data/lib/generators/pgbus/add_presence_generator.rb +4 -11
- data/lib/generators/pgbus/add_queue_states_generator.rb +4 -11
- data/lib/generators/pgbus/add_recurring_generator.rb +4 -11
- data/lib/generators/pgbus/add_stream_stats_generator.rb +4 -11
- data/lib/generators/pgbus/install_generator.rb +4 -11
- data/lib/generators/pgbus/migrate_job_locks_generator.rb +4 -11
- data/lib/generators/pgbus/migration_path.rb +28 -0
- data/lib/generators/pgbus/tune_autovacuum_generator.rb +4 -11
- data/lib/generators/pgbus/upgrade_pgmq_generator.rb +4 -11
- data/lib/pgbus/active_job/executor.rb +3 -1
- data/lib/pgbus/circuit_breaker.rb +1 -1
- data/lib/pgbus/client.rb +10 -3
- data/lib/pgbus/configuration.rb +22 -0
- data/lib/pgbus/engine.rb +1 -0
- data/lib/pgbus/error_reporter.rb +48 -0
- data/lib/pgbus/failed_event_recorder.rb +1 -8
- data/lib/pgbus/log_formatter.rb +96 -0
- data/lib/pgbus/outbox/poller.rb +4 -4
- data/lib/pgbus/process/consumer.rb +5 -1
- data/lib/pgbus/process/dispatcher.rb +1 -1
- data/lib/pgbus/process/supervisor.rb +6 -6
- data/lib/pgbus/process/worker.rb +8 -3
- data/lib/pgbus/queue_name_validator.rb +28 -9
- data/lib/pgbus/streams/key.rb +173 -0
- data/lib/pgbus/streams/streamable.rb +57 -0
- data/lib/pgbus/streams.rb +37 -0
- data/lib/pgbus/version.rb +1 -1
- data/lib/pgbus.rb +14 -0
- data/lib/tasks/pgbus_autovacuum.rake +40 -0
- metadata +7 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dca12989cdb8d34cd026facd0ecb71cc9df51fb966135806a858e1c4bdb0f7cc
|
|
4
|
+
data.tar.gz: 4f94274ec1bda644087f5711f2a75f8b1c70f5840f5e0d1d9a1b7ea137f6e3ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: decefd5c55ee2f4ca0c1aa6d52e1e1732f89ba3e789a0ae64c6b0bbd1cf60fe0d0c138dc87398f0a80b5e28d7e5cd7cd09eb44e2265265265adcfd9c0ee829f5
|
|
7
|
+
data.tar.gz: ad140f317e5de14558842881f2dd428281a8fb141986e7d8099976969a2d85b87dd08e7d01f64ebf5128f5b3174dd485b7af5c1f8d00b07bb4037ec095256c8c
|
data/README.md
CHANGED
|
@@ -23,6 +23,7 @@ PostgreSQL-native job processing and event bus for Rails, built on [PGMQ](https:
|
|
|
23
23
|
- [Circuit breaker and queue pause/resume](#circuit-breaker-and-queue-pauseresume)
|
|
24
24
|
- [Prefetch flow control](#prefetch-flow-control)
|
|
25
25
|
- [Worker recycling](#worker-recycling)
|
|
26
|
+
- [Retry backoff](#retry-backoff)
|
|
26
27
|
- [Routing and ordering](#routing-and-ordering)
|
|
27
28
|
- [Priority queues](#priority-queues)
|
|
28
29
|
- [Consumer priority](#consumer-priority)
|
|
@@ -31,6 +32,10 @@ PostgreSQL-native job processing and event bus for Rails, built on [PGMQ](https:
|
|
|
31
32
|
- [Batches](#batches)
|
|
32
33
|
- [Transactional outbox](#transactional-outbox)
|
|
33
34
|
- [Archive compaction](#archive-compaction)
|
|
35
|
+
- [Observability](#observability)
|
|
36
|
+
- [Error reporting](#error-reporting)
|
|
37
|
+
- [Structured logging](#structured-logging)
|
|
38
|
+
- [Queue health monitoring](#queue-health-monitoring)
|
|
34
39
|
- [Real-time broadcasts](#real-time-broadcasts-turbo-streams-replacement)
|
|
35
40
|
- [Operations](#operations)
|
|
36
41
|
- [CLI](#cli)
|
|
@@ -63,6 +68,10 @@ PostgreSQL-native job processing and event bus for Rails, built on [PGMQ](https:
|
|
|
63
68
|
- **Single active consumer** -- advisory-lock-based exclusive queue processing for strict ordering
|
|
64
69
|
- **Consumer priority** -- higher-priority workers get first dibs, lower-priority workers back off
|
|
65
70
|
- **Job uniqueness** -- prevent duplicate jobs with reaper-based crash recovery, no TTL-driven expiry
|
|
71
|
+
- **Retry backoff** -- exponential backoff with jitter for VT-based retries, per-job overrides
|
|
72
|
+
- **Error reporting** -- pluggable error reporters for APM integration (Appsignal, Sentry, etc.)
|
|
73
|
+
- **Structured logging** -- JSON log formatter with component extraction and thread-local context
|
|
74
|
+
- **Queue health** -- dead tuple monitoring, autovacuum tuning, Prometheus metrics
|
|
66
75
|
|
|
67
76
|
## Requirements
|
|
68
77
|
|
|
@@ -463,6 +472,34 @@ end
|
|
|
463
472
|
|
|
464
473
|
When a limit is hit, the worker drains its thread pool, exits, and the supervisor forks a fresh process. RSS memory is sampled from `/proc/self/statm` (Linux) or `ps -o rss` (macOS).
|
|
465
474
|
|
|
475
|
+
### Retry backoff
|
|
476
|
+
|
|
477
|
+
When a job fails, Pgbus extends the PGMQ visibility timeout with exponential backoff so retries are spread out instead of bunched at fixed intervals:
|
|
478
|
+
|
|
479
|
+
```ruby
|
|
480
|
+
Pgbus.configure do |config|
|
|
481
|
+
config.retry_backoff = 5 # base delay (seconds)
|
|
482
|
+
config.retry_backoff_max = 300 # cap at 5 minutes
|
|
483
|
+
config.retry_backoff_jitter = 0.15 # +-15% randomization
|
|
484
|
+
end
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
The delay formula is `base * 2^(attempt-1) * (1 + random_jitter)`. For a job that fails 4 times with defaults: ~5s, ~10s, ~20s, ~40s before hitting DLQ on the 5th read.
|
|
488
|
+
|
|
489
|
+
Jobs can override the global settings per-class:
|
|
490
|
+
|
|
491
|
+
```ruby
|
|
492
|
+
class FragileApiJob < ApplicationJob
|
|
493
|
+
include Pgbus::RetryBackoff::JobMixin
|
|
494
|
+
|
|
495
|
+
pgbus_retry_backoff base: 10, max: 600, jitter: 0.2
|
|
496
|
+
|
|
497
|
+
def perform(...)
|
|
498
|
+
# ...
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
```
|
|
502
|
+
|
|
466
503
|
### Async execution mode (fibers)
|
|
467
504
|
|
|
468
505
|
Workers can optionally execute jobs as fibers instead of threads. This is ideal for I/O-bound workloads (HTTP calls, email delivery, LLM API calls) where jobs spend most of their time waiting on network I/O.
|
|
@@ -662,6 +699,96 @@ as configuration. The dispatcher runs archive compaction as part of its
|
|
|
662
699
|
maintenance loop, deleting archived messages older than `archive_retention`
|
|
663
700
|
in batches to avoid long-running transactions.
|
|
664
701
|
|
|
702
|
+
## Observability
|
|
703
|
+
|
|
704
|
+
Error reporting, structured logging, and queue health monitoring.
|
|
705
|
+
|
|
706
|
+
### Error reporting
|
|
707
|
+
|
|
708
|
+
By default, Pgbus logs caught exceptions and continues. To route them to your APM service (Appsignal, Sentry, Honeybadger, etc.), push callable reporters onto `config.error_reporters`:
|
|
709
|
+
|
|
710
|
+
```ruby
|
|
711
|
+
Pgbus.configure do |c|
|
|
712
|
+
c.error_reporters << ->(ex, ctx) {
|
|
713
|
+
Appsignal.set_error(ex) { |t| t.set_tags(ctx) }
|
|
714
|
+
}
|
|
715
|
+
end
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
Each reporter receives `(exception, context_hash)`. The context hash includes keys like `action`, `queue`, `job_class`, and `msg_id` depending on the call site. Reporters that accept a third argument also receive the Pgbus configuration object.
|
|
719
|
+
|
|
720
|
+
Reporters are wired into all critical rescue paths: job execution failures, worker fetch/process errors, dispatcher maintenance, supervisor fork failures, circuit breaker trips, outbox publish errors, and failed event recording. Non-critical paths (dashboard queries, stat recording) remain log-only.
|
|
721
|
+
|
|
722
|
+
`ErrorReporter.report` is guaranteed to never raise — if a reporter or the logger itself throws, the error is swallowed silently. This preserves fault-tolerance invariants at every rescue site.
|
|
723
|
+
|
|
724
|
+
### Structured logging
|
|
725
|
+
|
|
726
|
+
Pgbus ships two log formatters inspired by Sidekiq's `Logger::Formatters`:
|
|
727
|
+
|
|
728
|
+
```ruby
|
|
729
|
+
Pgbus.configure do |c|
|
|
730
|
+
c.log_format = :json # or :text (default)
|
|
731
|
+
end
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
**Text format** (default):
|
|
735
|
+
|
|
736
|
+
```text
|
|
737
|
+
INFO 2025-01-15T10:30:00.000Z pid=1234 tid=abc queue=default: Starting job
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
**JSON format**:
|
|
741
|
+
|
|
742
|
+
```json
|
|
743
|
+
{"ts":"2025-01-15T10:30:00.000Z","pid":1234,"tid":"abc","lvl":"INFO","component":"Pgbus","msg":"Starting job","ctx":{"queue":"default"}}
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
The JSON formatter extracts `[Pgbus]` and `[Pgbus::Web]` prefixes from log messages into a separate `component` field so the `msg` field stays clean for log aggregators. Thread-local context can be added via `Pgbus::LogFormatter.with_context(queue: "default") { ... }` and appears under the `ctx` key.
|
|
747
|
+
|
|
748
|
+
You can also set a formatter directly on the logger:
|
|
749
|
+
|
|
750
|
+
```ruby
|
|
751
|
+
Pgbus.configure do |c|
|
|
752
|
+
c.logger.formatter = Pgbus::LogFormatter::JSON.new
|
|
753
|
+
end
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
### Queue health monitoring
|
|
757
|
+
|
|
758
|
+
The dashboard includes a **Queue Health** panel showing PostgreSQL vacuum stats per PGMQ table: dead tuple counts, live tuple counts, bloat ratio (dead / total), last vacuum age, and MVCC horizon age. The same stats appear on individual queue detail pages.
|
|
759
|
+
|
|
760
|
+
#### Autovacuum tuning
|
|
761
|
+
|
|
762
|
+
PGMQ queue tables have high insert/delete churn that overwhelms PostgreSQL's default autovacuum settings. Pgbus applies aggressive per-table tuning automatically:
|
|
763
|
+
|
|
764
|
+
- **New queues at runtime**: `Client#ensure_single_queue` applies tuning after `pgmq.create()`
|
|
765
|
+
- **Existing installations**: `rails generate pgbus:update` detects untuned tables
|
|
766
|
+
- **Fresh installs**: The install migration includes tuning for the default queue
|
|
767
|
+
|
|
768
|
+
To apply tuning manually or after `db:schema:load` (which loses `ALTER TABLE` settings):
|
|
769
|
+
|
|
770
|
+
```bash
|
|
771
|
+
rails generate pgbus:tune_autovacuum # Generate migration
|
|
772
|
+
rails generate pgbus:tune_autovacuum --database=pgbus # For separate database
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
The `pgbus:tune_autovacuum` rake task also hooks into `db:schema:load` automatically.
|
|
776
|
+
|
|
777
|
+
#### Prometheus metrics
|
|
778
|
+
|
|
779
|
+
When `config.metrics_enabled = true` (default), the dashboard exposes Prometheus-compatible gauges:
|
|
780
|
+
|
|
781
|
+
| Metric | Description |
|
|
782
|
+
|--------|-------------|
|
|
783
|
+
| `pgbus_table_dead_tuples` | Dead tuple count per PGMQ table |
|
|
784
|
+
| `pgbus_table_live_tuples` | Live tuple count per PGMQ table |
|
|
785
|
+
| `pgbus_table_bloat_ratio` | Dead / (dead + live) per table |
|
|
786
|
+
| `pgbus_table_last_vacuum_age_seconds` | Seconds since last vacuum per table |
|
|
787
|
+
| `pgbus_oldest_transaction_age_seconds` | MVCC horizon pin risk |
|
|
788
|
+
| `pgbus_worker_pool_capacity` | Total worker thread slots |
|
|
789
|
+
| `pgbus_worker_pool_busy` | Currently busy worker threads |
|
|
790
|
+
| `pgbus_worker_pool_utilization` | Busy / capacity ratio |
|
|
791
|
+
|
|
665
792
|
## Real-time broadcasts (turbo-streams replacement)
|
|
666
793
|
|
|
667
794
|
Pgbus ships a drop-in replacement for turbo-rails' `turbo_stream_from` helper that fixes several well-known ActionCable correctness bugs by using PGMQ message IDs as a replay cursor. Same API as turbo-rails. No Redis. No ActionCable. No lost messages on reconnect.
|
|
@@ -751,6 +878,34 @@ One Puma worker (or Falcon reactor) hosts one `Pgbus::Web::Streamer::Instance` s
|
|
|
751
878
|
|
|
752
879
|
Per-stream retention is handled by the main pgbus dispatcher process on the same interval as the dispatcher's `ARCHIVE_COMPACTION_INTERVAL` constant. Streams default to a 5-minute retention because SSE clients reconnect within seconds; chat-style applications override the retention to days via `streams_retention`.
|
|
753
880
|
|
|
881
|
+
### Stream name helpers
|
|
882
|
+
|
|
883
|
+
Apps using UUID primary keys with turbo-rails-style dom IDs can hit PGMQ's 47-character queue-name ceiling (`"gid://app/Ai::Chat/9c14e8b2-...:messages"` exceeds the limit before the `pgbus_` prefix is even added). Pgbus provides helpers to generate short, collision-safe stream names:
|
|
884
|
+
|
|
885
|
+
```ruby
|
|
886
|
+
# In your ApplicationRecord
|
|
887
|
+
class ApplicationRecord < ActiveRecord::Base
|
|
888
|
+
primary_abstract_class
|
|
889
|
+
include Pgbus::Streams::Streamable
|
|
890
|
+
end
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
This gives every model `short_id` (16-hex SHA-256 prefix of the GlobalID) and `to_stream_key`:
|
|
894
|
+
|
|
895
|
+
```ruby
|
|
896
|
+
chat = Ai::Chat.find("9c14e8b2-...")
|
|
897
|
+
chat.short_id # => "ai_chat_a3f8c1e9d2b47610"
|
|
898
|
+
chat.to_stream_key # => "ai_chat_a3f8c1e9d2b47610"
|
|
899
|
+
|
|
900
|
+
# Compose multi-part stream names
|
|
901
|
+
Pgbus.stream_key(chat, :messages) # => "ai_chat_a3f8c1e9d2b47610_messages"
|
|
902
|
+
|
|
903
|
+
# Use in views
|
|
904
|
+
<%= pgbus_stream_from Pgbus.stream_key(@chat, :messages) %>
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
The budget is computed from `config.queue_prefix` at call time so prefix overrides adjust automatically. If a stream name exceeds the budget, `Pgbus::Streams::StreamNameTooLong` is raised immediately with the offending name, computed budget, and a pointer to `Pgbus.stream_key` — before PGMQ is ever touched.
|
|
908
|
+
|
|
754
909
|
### Transactional broadcasts
|
|
755
910
|
|
|
756
911
|
**This is the feature no other Rails real-time stack can offer.** A broadcast issued inside an open ActiveRecord transaction is deferred until the transaction commits. If it rolls back, the broadcast silently drops — clients never see the change that the database never persisted.
|
|
@@ -1001,6 +1156,8 @@ Pgbus uses these tables (created via PGMQ and migrations):
|
|
|
1001
1156
|
| `pgbus_outbox_entries` | Transactional outbox entries pending publication |
|
|
1002
1157
|
| `pgbus_recurring_tasks` | Recurring job definitions |
|
|
1003
1158
|
| `pgbus_recurring_executions` | Recurring job execution history |
|
|
1159
|
+
| `pgbus_presence_members` | Stream presence tracking (who is subscribed) |
|
|
1160
|
+
| `pgbus_stream_stats` | Stream broadcast/connect/disconnect metrics (opt-in) |
|
|
1004
1161
|
|
|
1005
1162
|
### Switching from another backend
|
|
1006
1163
|
|
|
@@ -1058,6 +1215,9 @@ PostgreSQL + PGMQ
|
|
|
1058
1215
|
| `polling_interval` | `0.1` | Seconds between polls (LISTEN/NOTIFY is primary) |
|
|
1059
1216
|
| `visibility_timeout` | `30` | Time before unacked message becomes visible again. Accepts seconds or `ActiveSupport::Duration` (e.g. `10.minutes`) |
|
|
1060
1217
|
| `max_retries` | `5` | Failed reads before routing to dead letter queue |
|
|
1218
|
+
| `retry_backoff` | `5` | Base delay in seconds for VT-based retry backoff (exponential: `base * 2^(attempt-1)`) |
|
|
1219
|
+
| `retry_backoff_max` | `300` | Maximum retry delay in seconds (caps the exponential curve) |
|
|
1220
|
+
| `retry_backoff_jitter` | `0.15` | Jitter factor (0-1) added to retry delays to spread retries |
|
|
1061
1221
|
| `max_jobs_per_worker` | `nil` | Recycle worker after N jobs (nil = unlimited) |
|
|
1062
1222
|
| `max_memory_mb` | `nil` | Recycle worker when memory exceeds N MB |
|
|
1063
1223
|
| `max_worker_lifetime` | `nil` | Recycle worker after N seconds. Accepts seconds or Duration. |
|
|
@@ -1080,6 +1240,12 @@ PostgreSQL + PGMQ
|
|
|
1080
1240
|
| `web_live_updates` | `true` | Enable Turbo Frames auto-refresh on dashboard |
|
|
1081
1241
|
| `stats_enabled` | `true` | Record job execution stats for insights dashboard |
|
|
1082
1242
|
| `stats_retention` | `30.days` | How long to keep job stats. Accepts seconds, Duration, or `nil` to disable cleanup |
|
|
1243
|
+
| `streams_stats_enabled` | `false` | Record stream broadcast/connect/disconnect stats (opt-in, can be high volume) |
|
|
1244
|
+
| `streams_path` | `nil` | Custom URL path for the SSE endpoint (nil = auto-detected from engine mount) |
|
|
1245
|
+
| `execution_mode` | `:threads` | Global execution mode (`:threads` or `:async`). Per-worker override via capsule config. |
|
|
1246
|
+
| `error_reporters` | `[]` | Array of callables invoked on caught exceptions. Each receives `(exception, context_hash)`. |
|
|
1247
|
+
| `log_format` | `:text` | Log formatter (`:text` or `:json`). Sets `logger.formatter` automatically. |
|
|
1248
|
+
| `metrics_enabled` | `true` | Enable Prometheus-compatible metrics on the dashboard |
|
|
1083
1249
|
|
|
1084
1250
|
## Development
|
|
1085
1251
|
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddFailedEventsIndexGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_failed_events_unique_index.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_failed_events_unique_index.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_failed_events_unique_index.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_failed_events_unique_index.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_failed_events_unique_index.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -42,10 +39,6 @@ module Pgbus
|
|
|
42
39
|
def migration_version
|
|
43
40
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
44
41
|
end
|
|
45
|
-
|
|
46
|
-
def separate_database?
|
|
47
|
-
options[:database].present?
|
|
48
|
-
end
|
|
49
42
|
end
|
|
50
43
|
end
|
|
51
44
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddJobLocksGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_job_locks.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_job_locks.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_job_locks.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_job_locks.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_job_locks.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -43,10 +40,6 @@ module Pgbus
|
|
|
43
40
|
def migration_version
|
|
44
41
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
45
42
|
end
|
|
46
|
-
|
|
47
|
-
def separate_database?
|
|
48
|
-
options[:database].present?
|
|
49
|
-
end
|
|
50
43
|
end
|
|
51
44
|
end
|
|
52
45
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddJobStatsGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_job_stats.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_job_stats.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_job_stats.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_job_stats.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_job_stats.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -43,10 +40,6 @@ module Pgbus
|
|
|
43
40
|
def migration_version
|
|
44
41
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
45
42
|
end
|
|
46
|
-
|
|
47
|
-
def separate_database?
|
|
48
|
-
options[:database].present?
|
|
49
|
-
end
|
|
50
43
|
end
|
|
51
44
|
end
|
|
52
45
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddJobStatsLatencyGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_job_stats_latency.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_job_stats_latency.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_job_stats_latency.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_job_stats_latency.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_job_stats_latency.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -43,10 +40,6 @@ module Pgbus
|
|
|
43
40
|
def migration_version
|
|
44
41
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
45
42
|
end
|
|
46
|
-
|
|
47
|
-
def separate_database?
|
|
48
|
-
options[:database].present?
|
|
49
|
-
end
|
|
50
43
|
end
|
|
51
44
|
end
|
|
52
45
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddJobStatsQueueIndexGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_job_stats_queue_index.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_job_stats_queue_index.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_job_stats_queue_index.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_job_stats_queue_index.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_job_stats_queue_index.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -44,10 +41,6 @@ module Pgbus
|
|
|
44
41
|
def migration_version
|
|
45
42
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
46
43
|
end
|
|
47
|
-
|
|
48
|
-
def separate_database?
|
|
49
|
-
options[:database].present?
|
|
50
|
-
end
|
|
51
44
|
end
|
|
52
45
|
end
|
|
53
46
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddOutboxGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_outbox.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_outbox.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_outbox.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_outbox.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_outbox.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -43,10 +40,6 @@ module Pgbus
|
|
|
43
40
|
def migration_version
|
|
44
41
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
45
42
|
end
|
|
46
|
-
|
|
47
|
-
def separate_database?
|
|
48
|
-
options[:database].present?
|
|
49
|
-
end
|
|
50
43
|
end
|
|
51
44
|
end
|
|
52
45
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddPresenceGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_presence.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_presence.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_presence.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_presence.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_presence.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -46,10 +43,6 @@ module Pgbus
|
|
|
46
43
|
def migration_version
|
|
47
44
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
48
45
|
end
|
|
49
|
-
|
|
50
|
-
def separate_database?
|
|
51
|
-
options[:database].present?
|
|
52
|
-
end
|
|
53
46
|
end
|
|
54
47
|
end
|
|
55
48
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddQueueStatesGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_queue_states.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_queue_states.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_queue_states.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_queue_states.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_queue_states.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -42,10 +39,6 @@ module Pgbus
|
|
|
42
39
|
def migration_version
|
|
43
40
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
44
41
|
end
|
|
45
|
-
|
|
46
|
-
def separate_database?
|
|
47
|
-
options[:database].present?
|
|
48
|
-
end
|
|
49
42
|
end
|
|
50
43
|
end
|
|
51
44
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddRecurringGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_recurring_tables.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_recurring_tables.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_recurring_tables.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_recurring_tables.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_recurring_tables.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def create_recurring_config
|
|
@@ -47,10 +44,6 @@ module Pgbus
|
|
|
47
44
|
def migration_version
|
|
48
45
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
49
46
|
end
|
|
50
|
-
|
|
51
|
-
def separate_database?
|
|
52
|
-
options[:database].present?
|
|
53
|
-
end
|
|
54
47
|
end
|
|
55
48
|
end
|
|
56
49
|
end
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require "rails/generators/active_record"
|
|
5
|
+
require_relative "migration_path"
|
|
5
6
|
|
|
6
7
|
module Pgbus
|
|
7
8
|
module Generators
|
|
8
9
|
class AddStreamStatsGenerator < Rails::Generators::Base
|
|
9
10
|
include ActiveRecord::Generators::Migration
|
|
11
|
+
include MigrationPath
|
|
10
12
|
|
|
11
13
|
source_root File.expand_path("templates", __dir__)
|
|
12
14
|
|
|
@@ -18,13 +20,8 @@ module Pgbus
|
|
|
18
20
|
desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
|
|
19
21
|
|
|
20
22
|
def create_migration_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"db/pgbus_migrate/add_pgbus_stream_stats.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "add_stream_stats.rb.erb",
|
|
26
|
-
"db/migrate/add_pgbus_stream_stats.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "add_stream_stats.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "add_pgbus_stream_stats.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -45,10 +42,6 @@ module Pgbus
|
|
|
45
42
|
def migration_version
|
|
46
43
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
47
44
|
end
|
|
48
|
-
|
|
49
|
-
def separate_database?
|
|
50
|
-
options[:database].present?
|
|
51
|
-
end
|
|
52
45
|
end
|
|
53
46
|
end
|
|
54
47
|
end
|