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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b45ea024487cd58842efb84ffb49a8a838a087c3302fc1411d02ec1afc646c2
4
- data.tar.gz: 81900cffddb22af277e55be4c558316b9e0a61e3c9d9618f8d47ae1019f479ab
3
+ metadata.gz: 205fff146002126edb7d725c1897ed7e3dc6bedc78539f0d21e707e22c5aeee0
4
+ data.tar.gz: 5aa57b08c21c7e86fdd6b44f9b2a4a679b2cf6c3e7628ab99f932757b46974ab
5
5
  SHA512:
6
- metadata.gz: 52657842594b2e36b7ac7f658b2c3a56b3e4c6a4d7b22896dd1fade2daa34c7d7a4a9884c374930b055180b46078b72b2c6bdddf2a6b8a518ea67528e8b58b56
7
- data.tar.gz: 7252cd8c30c701ee033cf7244ed668e9b23d9c9b0f48d958835eafe59a0419c0df60a05e09e580ebb798bec704e44708bd12905cf658669494ed58fa6a3082f6
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 d0d535b2aac27e3caa5eaeef69e117772e334f44
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
Binary file
data/Dockerfile CHANGED
@@ -17,13 +17,8 @@ RUN gem update --system && gem install bundler && gem install rails
17
17
 
18
18
  WORKDIR /usr/src/app
19
19
 
20
- COPY Gemfile .
21
- COPY Gemfile.lock .
22
-
23
20
  COPY . .
24
21
 
25
22
  RUN bundle install
26
23
 
27
- COPY . .
28
-
29
24
  CMD ["irb"]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- koyo-postgres-replication (0.1.5.pre)
4
+ koyo-postgres-replication (0.1.6.pre)
5
5
  pg (~> 1.1)
6
6
  rack (~> 2.0, >= 2.0.0)
7
7
  rails (~> 7.0)
data/README.md CHANGED
@@ -4,9 +4,63 @@
4
4
 
5
5
  効用 koyo - Japanese for utility
6
6
 
7
- ## Replcation slots
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
@@ -1,5 +1,10 @@
1
1
  # Koyo Postgres Replication Changelog
2
2
 
3
+ ## 0.1.6.pre
4
+
5
+ - Clean up docker config
6
+ - Clean up README/doc
7
+
3
8
  ## 0.1.5.pre
4
9
 
5
10
  - Yard doc gemspec change to get it to show up in rubygems
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Koyo
4
4
  module Repl
5
- VERSION = '0.1.5.pre'
5
+ VERSION = '0.1.6.pre'
6
6
  end
7
7
  end
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.5.pre
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-21 00:00:00.000000000 Z
11
+ date: 2023-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg