koyo-postgres-replication 0.1.5.pre → 0.1.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- 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 +56 -2
- data/changelog.md +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: 205fff146002126edb7d725c1897ed7e3dc6bedc78539f0d21e707e22c5aeee0
|
4
|
+
data.tar.gz: 5aa57b08c21c7e86fdd6b44f9b2a4a679b2cf6c3e7628ab99f932757b46974ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13a8079535f071892ce0916853c6ddb2f197d355dbe780889c80d67313254632365e6a2a29a171f3dcbba6811bf6f77f9be59a26fe9822abbf56cace481cd41b
|
7
|
+
data.tar.gz: 20db2d8d865adc610b433673b44c93528cc490b43f7ac430aaf4a8924f10a14e552e7ea8e986790226bab27ce3e4835f900daebddf6252f27133fd5b9f1faba3
|
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
|
|
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.1.
|
4
|
+
version: 0.1.6.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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|