koyo-postgres-replication 0.1.5.pre → 7.0.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/.yardoc/checksums +1 -1
- data/.yardoc/objects/root.dat +0 -0
- data/Dockerfile +0 -5
- data/Gemfile.lock +1 -1
- data/README.md +68 -2
- data/changelog.md +5 -0
- data/lib/koyo/repl/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: b442425bb2a188ad51685679aef54801f99c13c09d37c31a41bada30d02dca9e
|
4
|
+
data.tar.gz: 57d47436468e45514b37859159865aad5814102e45b0a38e0c3b844b9ada6109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4282f4ed1ab6425c860b407cb350322ceb2dd94c604dd4c92024094c8e3768852d8420ff8ad7e63771c2feceaa6589b375b1c82ad36597470e42fefc110286c
|
7
|
+
data.tar.gz: 9e9b7ea6672422be740574d4816e8e441269f003658c94e42c8561c53ba4f64ee2e4f52b535c55cb3eec4168729a865ed84ab5505e03eeed80f1b6ef4e33ac8f
|
data/.yardoc/checksums
CHANGED
@@ -4,7 +4,7 @@ lib/koyo/repl/mod.rb 92b54b56643b06fdc74adc65dc04460f631d4036
|
|
4
4
|
lib/koyo/repl/data.rb cb847585c0f439b9f645b5ebd7fa3b96e08b94ff
|
5
5
|
lib/koyo/repl/install.rb 9b19b7bb74d084882a1f726693bac2d693015daa
|
6
6
|
lib/koyo/repl/railtie.rb 9c560c38f4663edda57aa39c9bb4bd9411daabbd
|
7
|
-
lib/koyo/repl/version.rb
|
7
|
+
lib/koyo/repl/version.rb a05897446d0fc22220b2393f10f0ab1f4dbba1d8
|
8
8
|
lib/koyo/repl/data_row.rb 46bd0b440721f3b0ddcded3fef1817ca5d77cb35
|
9
9
|
lib/koyo/repl/database.rb 719f2723b83a927e0524f6dea79393caaeba0514
|
10
10
|
lib/koyo/repl/diagnostics.rb 93226c47642c5e20f615425aff8a0c0ba988b07b
|
data/.yardoc/objects/root.dat
CHANGED
Binary file
|
data/Dockerfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,9 +4,63 @@
|
|
4
4
|
|
5
5
|
効用 koyo - Japanese for utility
|
6
6
|
|
7
|
-
##
|
7
|
+
## What is this?
|
8
8
|
|
9
|
-
This gem tries to simplify dealing with a `replication slot` in Postgres.
|
9
|
+
This gem tries to simplify dealing with a `replication slot` in Postgres. It
|
10
|
+
gives you a simple way to capture events in your Rails app when your Postgres
|
11
|
+
DB has a create, update, delete event. You can manage this from one class, or
|
12
|
+
manage this on a table-by-table basis within ActiveRecord Models.
|
13
|
+
|
14
|
+
Example of catch all:
|
15
|
+
|
16
|
+
```
|
17
|
+
class KoyoReplHandlerService < Koyo::Repl::EventHandlerService
|
18
|
+
class << self
|
19
|
+
# This is called whenever a create/update/delete action happens
|
20
|
+
# @param (Koyo::Repl::DataRow) row is docuemented in the wiki at
|
21
|
+
# https://github.com/wiseleyb/koyo-postgres-replication/wiki/Koyo::Repl::DataRow-data-spec
|
22
|
+
def koyo_handle_all_replication(row)
|
23
|
+
case row.kind
|
24
|
+
when 'insert'
|
25
|
+
case row.table
|
26
|
+
when 'users'
|
27
|
+
# Do something with data... like update some api
|
28
|
+
# It's important to do this async (active-job/sidekiq) so you
|
29
|
+
# don't back up the replication slot
|
30
|
+
UpdateSomeApi.performn_async(row.id)
|
31
|
+
# This job would do something like:
|
32
|
+
# User.find(row.id); Call some API with data
|
33
|
+
when 'delete'
|
34
|
+
when 'update'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Example of model callback:
|
41
|
+
|
42
|
+
```
|
43
|
+
class User < ApplicationRecord
|
44
|
+
include Koyo::Repl::Mod
|
45
|
+
koyo_repl_handler :handle_replication
|
46
|
+
|
47
|
+
# This is called when a row is created/updated/deleted for the users table
|
48
|
+
# @param (Koyo::Repl::DataRow) row is docuemented in the wiki at
|
49
|
+
# https://github.com/wiseleyb/koyo-postgres-replication/wiki/Koyo::Repl::DataRow-data-spec
|
50
|
+
def self.handle_replication(row)
|
51
|
+
case row.kind
|
52
|
+
when 'insert'
|
53
|
+
# Do something with data... like update some api
|
54
|
+
# It's important to do this async (active-job/sidekiq) so you
|
55
|
+
# don't back up the replication slot
|
56
|
+
UpdateSomeApi.performn_async(row.id)
|
57
|
+
# This job would do something like:
|
58
|
+
# User.find(row.id); Call some API with data
|
59
|
+
when 'delete'
|
60
|
+
when 'update'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
10
64
|
|
11
65
|
### What is a replication slot?
|
12
66
|
|
@@ -36,6 +90,18 @@ wiki](https://github.com/wiseleyb/koyo-postgres-replication/wiki/Configuring-Pos
|
|
36
90
|
|
37
91
|
Add to Gemfile:
|
38
92
|
|
93
|
+
### Versions
|
94
|
+
|
95
|
+
The `main` branch is always the latest code. Branches contain versions that are specific to Rails.
|
96
|
+
|
97
|
+
|Rails|Branch|Gemfile|
|
98
|
+
|---|---|---|
|
99
|
+
|7|[verions/7.0.0](https://github.com/wiseleyb/koyo-postgres-replication/tree/versions/7.0.0)|`gem 'koyo-postgres-replication', '~> 7.0', require: 'koyo'`|
|
100
|
+
|6|coming soon|n/a|
|
101
|
+
|5|coming soon|n/a|
|
102
|
+
|4|coming soon|n/a|
|
103
|
+
|3|probably not coming soon|n/a|
|
104
|
+
|
39
105
|
```
|
40
106
|
gem 'koyo-postgres-replication', require: 'koyo'
|
41
107
|
```
|
data/changelog.md
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.
|
4
|
+
version: 7.0.0
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -164,9 +164,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: 2.7.0
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
|
-
- - "
|
167
|
+
- - ">="
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version:
|
169
|
+
version: '0'
|
170
170
|
requirements: []
|
171
171
|
rubygems_version: 3.4.10
|
172
172
|
signing_key:
|