pgbus 0.6.8 → 0.6.9
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/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/engine.rb +1 -0
- data/lib/pgbus/version.rb +1 -1
- data/lib/tasks/pgbus_autovacuum.rake +40 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84c8f674c6aa6d83d0120f586b93f0fc4126ccb5d72378ec04a9b8cb3d464677
|
|
4
|
+
data.tar.gz: 2544b1be7c34ccf50493ce0af717c3069e979d95ded26197340d8133d637378f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb329bb54c6eb7da4341eb8050657007d4fe057e862db7b8ef3c6cb0612abff33eaa383d7ea0ce00844dab1a532bd4b45ad3c52618c9ef45b7f9cf9d693ba199
|
|
7
|
+
data.tar.gz: 8ed028896561f51cb8a904f8e692125e6e61335501fceae366f5cda3f22daf7379b1b83d472df940c4965e2f0b2e00aed30ab90e3227d185e797ee17fb9654b6
|
|
@@ -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
|
|
@@ -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 InstallGenerator < 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
|
|
|
@@ -25,13 +27,8 @@ module Pgbus
|
|
|
25
27
|
"Migrations go to db/pgbus_migrate/ and schema to db/pgbus_schema.rb"
|
|
26
28
|
|
|
27
29
|
def create_migration_file
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"db/pgbus_migrate/create_pgbus_tables.rb"
|
|
31
|
-
else
|
|
32
|
-
migration_template "migration.rb.erb",
|
|
33
|
-
"db/migrate/create_pgbus_tables.rb"
|
|
34
|
-
end
|
|
30
|
+
migration_template "migration.rb.erb",
|
|
31
|
+
File.join(pgbus_migrate_path, "create_pgbus_tables.rb")
|
|
35
32
|
end
|
|
36
33
|
|
|
37
34
|
def create_config_file
|
|
@@ -121,10 +118,6 @@ module Pgbus
|
|
|
121
118
|
def database_name
|
|
122
119
|
options[:database]
|
|
123
120
|
end
|
|
124
|
-
|
|
125
|
-
def separate_database?
|
|
126
|
-
database_name.present?
|
|
127
|
-
end
|
|
128
121
|
end
|
|
129
122
|
end
|
|
130
123
|
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 MigrateJobLocksGenerator < 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/migrate_pgbus_job_locks_to_uniqueness_keys.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "migrate_job_locks_to_uniqueness_keys.rb.erb",
|
|
26
|
-
"db/migrate/migrate_pgbus_job_locks_to_uniqueness_keys.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "migrate_job_locks_to_uniqueness_keys.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "migrate_pgbus_job_locks_to_uniqueness_keys.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_install
|
|
@@ -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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pgbus
|
|
4
|
+
module Generators
|
|
5
|
+
# Shared migration path logic for all pgbus generators.
|
|
6
|
+
#
|
|
7
|
+
# When --database is passed, uses Rails' built-in db_migrate_path which
|
|
8
|
+
# reads migrations_paths from database.yml. This is the standard Rails
|
|
9
|
+
# multi-database mechanism and respects custom paths like db/pgbus_migrate/.
|
|
10
|
+
#
|
|
11
|
+
# Falls back to db/migrate/ when no --database is set (single-database mode).
|
|
12
|
+
module MigrationPath
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def pgbus_migrate_path
|
|
16
|
+
if separate_database?
|
|
17
|
+
db_migrate_path
|
|
18
|
+
else
|
|
19
|
+
"db/migrate"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def separate_database?
|
|
24
|
+
options[:database].present?
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
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 TuneAutovacuumGenerator < 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/tune_pgbus_autovacuum.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "tune_autovacuum.rb.erb",
|
|
26
|
-
"db/migrate/tune_pgbus_autovacuum.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "tune_autovacuum.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "tune_pgbus_autovacuum.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 UpgradePgmqGenerator < 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/upgrade_pgmq_to_v#{target_version_slug}.rb"
|
|
24
|
-
else
|
|
25
|
-
migration_template "upgrade_pgmq.rb.erb",
|
|
26
|
-
"db/migrate/upgrade_pgmq_to_v#{target_version_slug}.rb"
|
|
27
|
-
end
|
|
23
|
+
migration_template "upgrade_pgmq.rb.erb",
|
|
24
|
+
File.join(pgbus_migrate_path, "upgrade_pgmq_to_v#{target_version_slug}.rb")
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def display_post_upgrade
|
|
@@ -51,10 +48,6 @@ module Pgbus
|
|
|
51
48
|
def target_version_slug
|
|
52
49
|
target_version.tr(".", "_")
|
|
53
50
|
end
|
|
54
|
-
|
|
55
|
-
def separate_database?
|
|
56
|
-
options[:database].present?
|
|
57
|
-
end
|
|
58
51
|
end
|
|
59
52
|
end
|
|
60
53
|
end
|
data/lib/pgbus/engine.rb
CHANGED
|
@@ -47,6 +47,7 @@ module Pgbus
|
|
|
47
47
|
rake_tasks do
|
|
48
48
|
load File.expand_path("../tasks/pgbus_pgmq.rake", __dir__)
|
|
49
49
|
load File.expand_path("../tasks/pgbus_streams.rake", __dir__)
|
|
50
|
+
load File.expand_path("../tasks/pgbus_autovacuum.rake", __dir__)
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
initializer "pgbus.i18n" do
|
data/lib/pgbus/version.rb
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :pgbus do
|
|
4
|
+
desc "Apply autovacuum tuning to PGMQ queue/archive tables and high-churn pgbus tables"
|
|
5
|
+
task tune_autovacuum: :environment do
|
|
6
|
+
require "pgbus/autovacuum_tuning"
|
|
7
|
+
|
|
8
|
+
conn = Pgbus.configuration.connects_to ? Pgbus::BusRecord.connection : ActiveRecord::Base.connection
|
|
9
|
+
|
|
10
|
+
# Only run if pgmq schema exists (tables may not be created yet during
|
|
11
|
+
# initial setup — the install migration handles tuning itself).
|
|
12
|
+
pgmq_exists = conn.select_value(
|
|
13
|
+
"SELECT 1 FROM information_schema.schemata WHERE schema_name = 'pgmq'"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
unless pgmq_exists
|
|
17
|
+
puts "[pgbus] PGMQ schema not found — skipping autovacuum tuning."
|
|
18
|
+
next
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
puts "[pgbus] Applying autovacuum tuning to PGMQ queue/archive tables..."
|
|
22
|
+
conn.execute(Pgbus::AutovacuumTuning.sql_for_all_queues)
|
|
23
|
+
|
|
24
|
+
puts "[pgbus] Applying autovacuum tuning to high-churn pgbus tables..."
|
|
25
|
+
conn.execute(Pgbus::AutovacuumTuning.sql_for_high_churn_tables)
|
|
26
|
+
|
|
27
|
+
puts "[pgbus] Autovacuum tuning complete."
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Reapply autovacuum settings after schema:load since Ruby-format schema.rb
|
|
32
|
+
# does not preserve ALTER TABLE ... SET (reloptions). This is a no-op if the
|
|
33
|
+
# tables don't exist yet (IF EXISTS guards in the SQL).
|
|
34
|
+
%w[db:schema:load db:schema:load:pgbus].each do |task_name|
|
|
35
|
+
next unless Rake::Task.task_defined?(task_name)
|
|
36
|
+
|
|
37
|
+
Rake::Task[task_name].enhance do
|
|
38
|
+
Rake::Task["pgbus:tune_autovacuum"].invoke if Rake::Task.task_defined?("pgbus:tune_autovacuum")
|
|
39
|
+
end
|
|
40
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgbus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikael Henriksson
|
|
@@ -215,6 +215,7 @@ files:
|
|
|
215
215
|
- lib/generators/pgbus/add_stream_stats_generator.rb
|
|
216
216
|
- lib/generators/pgbus/install_generator.rb
|
|
217
217
|
- lib/generators/pgbus/migrate_job_locks_generator.rb
|
|
218
|
+
- lib/generators/pgbus/migration_path.rb
|
|
218
219
|
- lib/generators/pgbus/templates/add_failed_events_unique_index.rb.erb
|
|
219
220
|
- lib/generators/pgbus/templates/add_job_locks.rb.erb
|
|
220
221
|
- lib/generators/pgbus/templates/add_job_stats.rb.erb
|
|
@@ -319,6 +320,7 @@ files:
|
|
|
319
320
|
- lib/pgbus/web/streamer/registry.rb
|
|
320
321
|
- lib/pgbus/web/streamer/stream_event_dispatcher.rb
|
|
321
322
|
- lib/puma/plugin/pgbus_streams.rb
|
|
323
|
+
- lib/tasks/pgbus_autovacuum.rake
|
|
322
324
|
- lib/tasks/pgbus_pgmq.rake
|
|
323
325
|
- lib/tasks/pgbus_streams.rake
|
|
324
326
|
homepage: https://github.com/mhenrixon/pgbus
|