koyo-postgres-replication 0.1.3.pre → 0.1.4.pre
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/.yardoc/checksums +5 -5
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -1
- data/README.md +4 -0
- data/changelog.md +8 -0
- data/lib/koyo/repl/data_row.rb +13 -9
- data/lib/koyo/repl/postgres_server.rb +12 -12
- data/lib/koyo/repl/railtie.rb +5 -0
- data/lib/koyo/repl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7e309ca1f76d89a85e0d84b66fd54b629e7060ffd089a6a4383099230ccad9f
|
|
4
|
+
data.tar.gz: d387c7c45a91cf7500c83188688024fd8c08c97c4298fcc015d1d7b12adc425b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69dae55f084fc5d4206164d47e312d5bcbf530397190563126097fc3e0250760537ae1930b68228e18f7490e929e374af67663bb3ee8b6da99460dc718951bc6
|
|
7
|
+
data.tar.gz: 4c53b1c6a422c78f70885ac5db3a4951b8323b8ba9707771915cd4cbe933274d2697c467c2b75586ca9c77e2e5fd299cf8bdfdc5b011a39dc6efa2ab6288bb82
|
data/.yardoc/checksums
CHANGED
|
@@ -3,12 +3,12 @@ lib/koyo/repl/log.rb 811d21aa6f8843589b66da79a96a4e8b755fcc2d
|
|
|
3
3
|
lib/koyo/repl/mod.rb 92b54b56643b06fdc74adc65dc04460f631d4036
|
|
4
4
|
lib/koyo/repl/data.rb cb847585c0f439b9f645b5ebd7fa3b96e08b94ff
|
|
5
5
|
lib/koyo/repl/install.rb 9b19b7bb74d084882a1f726693bac2d693015daa
|
|
6
|
-
lib/koyo/repl/railtie.rb
|
|
7
|
-
lib/koyo/repl/version.rb
|
|
8
|
-
lib/koyo/repl/data_row.rb
|
|
9
|
-
lib/koyo/repl/database.rb
|
|
6
|
+
lib/koyo/repl/railtie.rb 9c560c38f4663edda57aa39c9bb4bd9411daabbd
|
|
7
|
+
lib/koyo/repl/version.rb d0d535b2aac27e3caa5eaeef69e117772e334f44
|
|
8
|
+
lib/koyo/repl/data_row.rb 46bd0b440721f3b0ddcded3fef1817ca5d77cb35
|
|
9
|
+
lib/koyo/repl/database.rb 719f2723b83a927e0524f6dea79393caaeba0514
|
|
10
10
|
lib/koyo/repl/diagnostics.rb 93226c47642c5e20f615425aff8a0c0ba988b07b
|
|
11
11
|
lib/koyo/repl/configuration.rb 8a32f819abf035340a3997d989ccafe0751d209e
|
|
12
|
-
lib/koyo/repl/postgres_server.rb
|
|
12
|
+
lib/koyo/repl/postgres_server.rb 3d564dff9e7820962da02f8a383a607fb72110dc
|
|
13
13
|
lib/koyo_postgres_replication.rb e3f4d905e3045b59f1f7c799d84cd9fde70eebd8
|
|
14
14
|
lib/koyo/repl/event_handler_service.rb 99b67bdcf3e0e92a04cd01bf8d05a4569b45d218
|
data/.yardoc/object_types
CHANGED
|
Binary file
|
data/.yardoc/objects/root.dat
CHANGED
|
Binary file
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
koyo-postgres-replication (0.1.
|
|
4
|
+
koyo-postgres-replication (0.1.4.pre)
|
|
5
5
|
pg (~> 1.1)
|
|
6
6
|
rack (~> 2.0, >= 2.0.0)
|
|
7
7
|
rails (~> 7.0)
|
|
@@ -78,6 +78,8 @@ GEM
|
|
|
78
78
|
ast (2.4.2)
|
|
79
79
|
base64 (0.1.1)
|
|
80
80
|
builder (3.2.4)
|
|
81
|
+
composite_primary_keys (14.0.6)
|
|
82
|
+
activerecord (~> 7.0.2)
|
|
81
83
|
concurrent-ruby (1.2.2)
|
|
82
84
|
crass (1.0.6)
|
|
83
85
|
date (3.3.3)
|
|
@@ -215,6 +217,7 @@ PLATFORMS
|
|
|
215
217
|
arm64-darwin-22
|
|
216
218
|
|
|
217
219
|
DEPENDENCIES
|
|
220
|
+
composite_primary_keys (~> 14.0)
|
|
218
221
|
debug
|
|
219
222
|
factory_bot_rails
|
|
220
223
|
ffaker
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Koyo::Postgres::Replication
|
|
2
2
|
|
|
3
3
|
例 rei - Japanese for example
|
|
4
|
+
|
|
4
5
|
効用 koyo - Japanese for utility
|
|
5
6
|
|
|
6
7
|
## Replcation slots
|
|
@@ -170,6 +171,9 @@ for sql examples on how to interact with replication slots.
|
|
|
170
171
|
|
|
171
172
|
## Yard Doc
|
|
172
173
|
|
|
174
|
+
Yard docs are up on
|
|
175
|
+
[RubyDoc.info](https://rubydoc.info/github/wiseleyb/koyo-postgres-replication/main)
|
|
176
|
+
|
|
173
177
|
Cheat sheets:
|
|
174
178
|
* https://gist.github.com/chetan/1827484
|
|
175
179
|
* https://kapeli.com/cheat_sheets/Yard.docset/Contents/Resources/Documents/index
|
data/changelog.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Koyo Postgres Replication Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.4.pre
|
|
4
|
+
|
|
5
|
+
- Add link to
|
|
6
|
+
[doc](https://rubydoc.info/github/wiseleyb/koyo-postgres-replication/main) in
|
|
7
|
+
README
|
|
8
|
+
- Fix issues around composite keys (multiple primary keys) [Issues
|
|
9
|
+
4](https://github.com/wiseleyb/koyo-postgres-replication/issues/4)
|
|
10
|
+
|
|
3
11
|
## 0.1.3.pre
|
|
4
12
|
|
|
5
13
|
- republishing yanked gem
|
data/lib/koyo/repl/data_row.rb
CHANGED
|
@@ -11,8 +11,10 @@ module Koyo
|
|
|
11
11
|
:kind, # insert/update/delete
|
|
12
12
|
:schema, # always public for this - not needed
|
|
13
13
|
:table, # table being changed
|
|
14
|
-
:id, # table.id
|
|
15
|
-
:id_type, # integer/uuid
|
|
14
|
+
:id, # table.id, null for composite keys
|
|
15
|
+
:id_type, # integer/uuid, null for composite keys
|
|
16
|
+
:ids, # for composite keys - array of ids
|
|
17
|
+
:id_types, # for composite keys - array of types
|
|
16
18
|
:columns, # all columns from table - array
|
|
17
19
|
:column_types, # all types of columns - array
|
|
18
20
|
:values # all values from table - array
|
|
@@ -34,12 +36,12 @@ module Koyo
|
|
|
34
36
|
# WARN: this breaks for multiple primary keys
|
|
35
37
|
def check_set_primary_keys
|
|
36
38
|
if @row['oldkeys']
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
@ids = Array.new(@row['oldkeys']['keyvalues'])
|
|
40
|
+
@id_types = Array.new(@row['oldkeys']['keytypes'])
|
|
41
|
+
if @row['oldkeys']['keynames'].size == 1
|
|
42
|
+
@id = @ids.first
|
|
43
|
+
@id_type = @id_types.first
|
|
39
44
|
end
|
|
40
|
-
|
|
41
|
-
@id = @row['oldkeys']['keyvalues'].first
|
|
42
|
-
@id_type = @row['oldkeys']['keytypes'].first
|
|
43
45
|
else
|
|
44
46
|
@id = val(:id)
|
|
45
47
|
@id_type = type(:id)
|
|
@@ -49,13 +51,15 @@ module Koyo
|
|
|
49
51
|
# Gets a value for a name from columnsvalues
|
|
50
52
|
# @param name column name
|
|
51
53
|
def val(name)
|
|
52
|
-
|
|
54
|
+
idx = columns.index(name.to_s)
|
|
55
|
+
idx ? values[idx] : nil
|
|
53
56
|
end
|
|
54
57
|
|
|
55
58
|
# Get a val type from columntypes
|
|
56
59
|
# @param name column name
|
|
57
60
|
def type(name)
|
|
58
|
-
|
|
61
|
+
idx = columns.index(name.to_s)
|
|
62
|
+
idx ? column_types[idx] : nil
|
|
59
63
|
end
|
|
60
64
|
end
|
|
61
65
|
end
|
|
@@ -62,6 +62,18 @@ module Koyo
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# Does a single check of the replication slot
|
|
66
|
+
# If test_mode=true uses peek, which will
|
|
67
|
+
# leave data in the replication slot (for testing/debugging)
|
|
68
|
+
def check
|
|
69
|
+
read_sql_results.each do |sql_res|
|
|
70
|
+
rows = Koyo::Repl::Data.new(sql_res).rows # returns ReplDataRow
|
|
71
|
+
rows.each do |row|
|
|
72
|
+
check_row(row)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
65
77
|
# Attempts to re-establish DB connection. If it finds any other
|
|
66
78
|
# error this is fatal and server crashes at this point
|
|
67
79
|
# @param [StandardError] err Error that kicked off this retry loop
|
|
@@ -121,18 +133,6 @@ module Koyo
|
|
|
121
133
|
@tick_tock = 0
|
|
122
134
|
end
|
|
123
135
|
|
|
124
|
-
# Does a single check of the replication slot
|
|
125
|
-
# If test_mode=true uses peek, which will
|
|
126
|
-
# leave data in the replication slot (for testing/debugging)
|
|
127
|
-
def check
|
|
128
|
-
read_sql_results.each do |sql_res|
|
|
129
|
-
rows = Koyo::Repl::Data.new(sql_res).rows # returns ReplDataRow
|
|
130
|
-
rows.each do |row|
|
|
131
|
-
check_row(row)
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
136
|
# Reads data from the replication slot
|
|
137
137
|
# Handles test_mode (so will only peek if true)
|
|
138
138
|
def read_sql_results
|
data/lib/koyo/repl/railtie.rb
CHANGED
data/lib/koyo/repl/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koyo-postgres-replication
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4.pre
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Wiseley
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-08-
|
|
11
|
+
date: 2023-08-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pg
|