pg_easy_replicate 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +14 -16
- data/README.md +10 -0
- data/lib/pg_easy_replicate/cli.rb +10 -0
- data/lib/pg_easy_replicate/stats.rb +26 -0
- data/lib/pg_easy_replicate/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5861f7f038a1d9c632eeab71e7195019041846f98f22297d3e148070e150f3f0
|
|
4
|
+
data.tar.gz: f3187c00bc0625954ac3c1b9f5a6847782383d198e5c04f2b6597d61a7d83e4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60fe3ae088cab65b1a1ec5168e62cfed7f1ef1141a85a438481b05b798e143d2728f970771092094ee9ef643fdced7373a361fee5dca36a27074799370f142e7
|
|
7
|
+
data.tar.gz: 4267418bfd99ab8327f0d89e20a85062d06e1b8a0b5d6086afdb531ce7f3f91229015c611c9629bb2c471fedddada07974954bffa0cbd3ca18cd1bf7c7ac6a05
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [0.3.2] - 2024-08-31
|
|
2
|
+
|
|
3
|
+
- DDL: Support table column rename - #157
|
|
4
|
+
|
|
5
|
+
## [0.3.0] - 2024-08-31
|
|
6
|
+
|
|
7
|
+
- Support DDL Tracking by - #155
|
|
8
|
+
- `recreate-indices-post-copy` now defaults to `false`
|
|
9
|
+
|
|
1
10
|
## [0.2.6] - 2024-06-04
|
|
2
11
|
|
|
3
12
|
- Quote table name in the VACUUM SQL - #118
|
data/Gemfile.lock
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pg_easy_replicate (0.3.
|
|
4
|
+
pg_easy_replicate (0.3.3)
|
|
5
5
|
ougai (~> 2.0.0)
|
|
6
6
|
pg (~> 1.5.3)
|
|
7
7
|
pg_query (~> 5.1.0)
|
|
8
|
-
sequel (>= 5.69, < 5.
|
|
8
|
+
sequel (>= 5.69, < 5.87)
|
|
9
9
|
thor (>= 1.2.2, < 1.4.0)
|
|
10
10
|
|
|
11
11
|
GEM
|
|
@@ -15,10 +15,10 @@ GEM
|
|
|
15
15
|
bigdecimal (3.1.8)
|
|
16
16
|
coderay (1.1.3)
|
|
17
17
|
diff-lcs (1.5.1)
|
|
18
|
-
google-protobuf (4.28.
|
|
18
|
+
google-protobuf (4.28.2-arm64-darwin)
|
|
19
19
|
bigdecimal
|
|
20
20
|
rake (>= 13)
|
|
21
|
-
google-protobuf (4.28.
|
|
21
|
+
google-protobuf (4.28.2-x86_64-linux)
|
|
22
22
|
bigdecimal
|
|
23
23
|
rake (>= 13)
|
|
24
24
|
haml (6.1.1)
|
|
@@ -31,24 +31,23 @@ GEM
|
|
|
31
31
|
oj (3.14.3)
|
|
32
32
|
ougai (2.0.0)
|
|
33
33
|
oj (~> 3.10)
|
|
34
|
-
parallel (1.
|
|
35
|
-
parser (3.3.
|
|
34
|
+
parallel (1.26.3)
|
|
35
|
+
parser (3.3.5.0)
|
|
36
36
|
ast (~> 2.4.1)
|
|
37
37
|
racc
|
|
38
|
-
pg (1.5.
|
|
38
|
+
pg (1.5.9)
|
|
39
39
|
pg_query (5.1.0)
|
|
40
40
|
google-protobuf (>= 3.22.3)
|
|
41
41
|
prettier_print (1.2.1)
|
|
42
42
|
pry (0.14.2)
|
|
43
43
|
coderay (~> 1.1)
|
|
44
44
|
method_source (~> 1.0)
|
|
45
|
-
racc (1.8.
|
|
45
|
+
racc (1.8.1)
|
|
46
46
|
rainbow (3.1.1)
|
|
47
47
|
rake (13.2.1)
|
|
48
48
|
rbs (3.1.0)
|
|
49
49
|
regexp_parser (2.9.2)
|
|
50
|
-
rexml (3.3.
|
|
51
|
-
strscan
|
|
50
|
+
rexml (3.3.9)
|
|
52
51
|
rspec (3.13.0)
|
|
53
52
|
rspec-core (~> 3.13.0)
|
|
54
53
|
rspec-expectations (~> 3.13.0)
|
|
@@ -73,7 +72,7 @@ GEM
|
|
|
73
72
|
rubocop-ast (>= 1.31.1, < 2.0)
|
|
74
73
|
ruby-progressbar (~> 1.7)
|
|
75
74
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
76
|
-
rubocop-ast (1.
|
|
75
|
+
rubocop-ast (1.32.3)
|
|
77
76
|
parser (>= 3.3.1.0)
|
|
78
77
|
rubocop-capybara (2.20.0)
|
|
79
78
|
rubocop (~> 1.41)
|
|
@@ -81,7 +80,7 @@ GEM
|
|
|
81
80
|
rubocop (~> 1.41)
|
|
82
81
|
rubocop-packaging (0.5.2)
|
|
83
82
|
rubocop (>= 1.33, < 2.0)
|
|
84
|
-
rubocop-performance (1.
|
|
83
|
+
rubocop-performance (1.22.1)
|
|
85
84
|
rubocop (>= 1.48.1, < 2.0)
|
|
86
85
|
rubocop-ast (>= 1.31.1, < 2.0)
|
|
87
86
|
rubocop-rake (0.6.0)
|
|
@@ -94,9 +93,8 @@ GEM
|
|
|
94
93
|
rubocop-rspec_rails (2.28.2)
|
|
95
94
|
rubocop (~> 1.40)
|
|
96
95
|
ruby-progressbar (1.13.0)
|
|
97
|
-
sequel (5.
|
|
96
|
+
sequel (5.86.0)
|
|
98
97
|
bigdecimal
|
|
99
|
-
strscan (3.1.0)
|
|
100
98
|
syntax_tree (6.2.0)
|
|
101
99
|
prettier_print (>= 1.2.0)
|
|
102
100
|
syntax_tree-haml (4.0.3)
|
|
@@ -108,9 +106,9 @@ GEM
|
|
|
108
106
|
rbs
|
|
109
107
|
syntax_tree (>= 2.0.1)
|
|
110
108
|
temple (0.10.1)
|
|
111
|
-
thor (1.3.
|
|
109
|
+
thor (1.3.2)
|
|
112
110
|
tilt (2.1.0)
|
|
113
|
-
unicode-display_width (2.
|
|
111
|
+
unicode-display_width (2.6.0)
|
|
114
112
|
|
|
115
113
|
PLATFORMS
|
|
116
114
|
arm64-darwin-22
|
data/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Battle tested in production at [Tines](https://www.tines.com/) 🚀
|
|
|
26
26
|
- [Listing DDL Changes](#listing-ddl-changes)
|
|
27
27
|
- [Applying DDL Changes](#applying-ddl-changes)
|
|
28
28
|
- [Stats](#stats)
|
|
29
|
+
- [Notify](#notify)
|
|
29
30
|
- [Performing switchover](#performing-switchover)
|
|
30
31
|
- [Replicating single database with custom tables](#replicating-single-database-with-custom-tables)
|
|
31
32
|
- [Exclude tables from replication](#exclude-tables-from-replication)
|
|
@@ -120,6 +121,7 @@ pg_easy_replicate commands:
|
|
|
120
121
|
pg_easy_replicate help [COMMAND] # Describe available commands or one specific command
|
|
121
122
|
pg_easy_replicate start_sync -g, --group-name=GROUP_NAME # Starts the logical replication from source database to target database provisioned in the group
|
|
122
123
|
pg_easy_replicate stats -g, --group-name=GROUP_NAME # Prints the statistics in JSON for the group
|
|
124
|
+
pg_easy_replicate notify -g, --group-name=GROUP_NAME, -u --url=URL_TO_NOTIFY # Sends notifications of all stats values for a group to a specified url
|
|
123
125
|
pg_easy_replicate stop_sync -g, --group-name=GROUP_NAME # Stop the logical replication from source database to target database provisioned in the group
|
|
124
126
|
pg_easy_replicate switchover -g, --group-name=GROUP_NAME # Puts the source database in read only mode after all the data is flushed and written
|
|
125
127
|
pg_easy_replicate version # Prints the version
|
|
@@ -276,6 +278,14 @@ $ pg_easy_replicate stats --group-name database-cluster-1
|
|
|
276
278
|
....
|
|
277
279
|
```
|
|
278
280
|
|
|
281
|
+
### Notify
|
|
282
|
+
|
|
283
|
+
You can send stats to an endpoint on an interval using notify. This can be configured to receieve the stats to this url on a frequency (default 10s). A timeout can also be configured for the request to the endpoint (default 10s). This gives you greater control over processing different events in the replication cycle in your workflow.
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
$ pg_easy_replicate notify --group-name database-cluster-1 --url https://example.com/webhook --frequency 10 --timeout 10
|
|
287
|
+
```
|
|
288
|
+
|
|
279
289
|
### Performing switchover
|
|
280
290
|
|
|
281
291
|
`pg_easy_replicate` doesn't kick off the switchover on its own. When you start the sync via `start_sync`, it starts the replication between the two databases. Once you have had the time to monitor stats and any other key metrics, you can kick off the `switchover`.
|
|
@@ -163,6 +163,16 @@ module PgEasyReplicate
|
|
|
163
163
|
end
|
|
164
164
|
end
|
|
165
165
|
|
|
166
|
+
desc "notify", "Sends a notification with replication status to a specified url"
|
|
167
|
+
method_option :group_name, aliases: "-g", required: true, desc: "Name of the group previously provisioned"
|
|
168
|
+
method_option :url, aliases: "-u", required: true, desc: "URL for notification"
|
|
169
|
+
method_option :frequency, aliases: "-f", type: :numeric, default: 10, desc: "Frequency for sending stats to the endpoint provided"
|
|
170
|
+
method_option :timeout, aliases: "-t", type: :numeric, default: 10, desc: "Timeout for the notify request"
|
|
171
|
+
|
|
172
|
+
def notify
|
|
173
|
+
PgEasyReplicate::Stats.notify(options[:group_name], options[:url], options[:frequency], options[:timeout])
|
|
174
|
+
end
|
|
175
|
+
|
|
166
176
|
desc "list_ddl_changes", "Lists recent DDL changes in the source database"
|
|
167
177
|
method_option :group_name,
|
|
168
178
|
aliases: "-g",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "net/http"
|
|
4
|
+
|
|
3
5
|
module PgEasyReplicate
|
|
4
6
|
class Stats
|
|
5
7
|
REPLICATION_STATE_MAP = {
|
|
@@ -39,6 +41,30 @@ module PgEasyReplicate
|
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
44
|
+
def notify(group_name, url, frequency = 10, timeout = 10)
|
|
45
|
+
loop do
|
|
46
|
+
stats = object(group_name)
|
|
47
|
+
uri = URI.parse(url)
|
|
48
|
+
|
|
49
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
50
|
+
http.use_ssl = (uri.scheme == "https")
|
|
51
|
+
http.open_timeout = timeout
|
|
52
|
+
http.read_timeout = timeout
|
|
53
|
+
|
|
54
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
|
55
|
+
request.content_type = "application/json"
|
|
56
|
+
request.body = stats.to_json
|
|
57
|
+
|
|
58
|
+
response = http.request(request)
|
|
59
|
+
|
|
60
|
+
puts "Notification sent: #{response.code} #{response.message}"
|
|
61
|
+
|
|
62
|
+
sleep(frequency)
|
|
63
|
+
end
|
|
64
|
+
rescue StandardError => e
|
|
65
|
+
abort_with("Notify failed with: #{e.message}")
|
|
66
|
+
end
|
|
67
|
+
|
|
42
68
|
# Get
|
|
43
69
|
def lag_stats(group_name)
|
|
44
70
|
sql = <<~SQL
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pg_easy_replicate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shayon Mukherjee
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ougai
|
|
@@ -61,7 +61,7 @@ dependencies:
|
|
|
61
61
|
version: '5.69'
|
|
62
62
|
- - "<"
|
|
63
63
|
- !ruby/object:Gem::Version
|
|
64
|
-
version: '5.
|
|
64
|
+
version: '5.87'
|
|
65
65
|
type: :runtime
|
|
66
66
|
prerelease: false
|
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -71,7 +71,7 @@ dependencies:
|
|
|
71
71
|
version: '5.69'
|
|
72
72
|
- - "<"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '5.
|
|
74
|
+
version: '5.87'
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: thor
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|