wal 0.0.3 → 0.0.4
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/exe/wal +19 -14
- data/lib/wal/version.rb +1 -1
- data/rbi/wal.rbi +20 -21
- 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: 9ae004595b321331dd26bb5fa7942bdc18d28d75aa79647d2d861352d94ab945
|
4
|
+
data.tar.gz: f7b2e1cf46055f9133b1aede3661774884a55780f5a430ed8d0be28fc45db642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42029a4c1ca4138c3e751667a62a19e3b08676c991940bad40caa7d1194fd4f8aa08161733ec860cca43a45745c68cf5f41371211f96c27b46b1e04ca672d1e2
|
7
|
+
data.tar.gz: f3b0c235c66b612c9772bd8c89d7beed90ab44875884be2af127f9e0cea147bde920903bacef74b7fca3a762b3c792eb97573998ec80a64d56d50d7e6e58cfaa
|
data/exe/wal
CHANGED
@@ -5,16 +5,20 @@ require "docopt"
|
|
5
5
|
begin
|
6
6
|
cli = Docopt.docopt(<<~DOCOPT)
|
7
7
|
Usage:
|
8
|
-
wal watch --watcher <watcher-class>
|
8
|
+
wal watch --watcher <watcher-class>
|
9
|
+
(--slot <replication-slot> | --tmp-slot)
|
10
|
+
[--publication=<publication>...]
|
11
|
+
[--replicator <replicator-class>]
|
12
|
+
|
9
13
|
wal start <config-file>
|
10
14
|
|
11
15
|
Options:
|
12
|
-
-h --help
|
13
|
-
--watcher=<watcher-class>
|
14
|
-
--slot=<replication-slot>
|
15
|
-
--tmp-slot
|
16
|
-
[--publication=<publication>...]
|
17
|
-
[--
|
16
|
+
-h --help Show this screen.
|
17
|
+
--watcher=<watcher-class> The watcher class to be used to listen for WAL changes.
|
18
|
+
--slot=<replication-slot> The replication slot that will be used.
|
19
|
+
--tmp-slot Use a temporary replication slot.
|
20
|
+
[--publication=<publication>...] Force using the informed Postgres publications.
|
21
|
+
[--replicator=<replicatior_class>] Change the replication driver class
|
18
22
|
DOCOPT
|
19
23
|
rescue Docopt::Exit => err
|
20
24
|
puts err.message
|
@@ -23,31 +27,32 @@ end
|
|
23
27
|
|
24
28
|
require "./config/environment"
|
25
29
|
|
30
|
+
db_config = ActiveRecord::Base.configurations.configs_for(name: "primary").configuration_hash
|
31
|
+
|
26
32
|
if cli["watch"]
|
27
33
|
watcher = cli["--watcher"].constantize.new
|
28
|
-
watcher = Wal::MonitoringWatcher.new(watcher) if cli["--with-timings"]
|
29
|
-
|
30
34
|
use_temporary_slot = cli["--tmp-slot"] || false
|
31
35
|
replication_slot = cli["--slot"]
|
32
36
|
replication_slot = replication_slot.presence || "wal_watcher_#{SecureRandom.alphanumeric(4)}" if use_temporary_slot
|
37
|
+
replicator = cli["--replicator"]&.constantize || Wal::Replicator
|
33
38
|
|
34
|
-
|
35
|
-
.new(replication_slot:, use_temporary_slot:)
|
39
|
+
replicator
|
40
|
+
.new(replication_slot:, use_temporary_slot:, db_config:)
|
36
41
|
.replicate_forever(watcher, publications: cli["--publication"])
|
37
42
|
|
38
43
|
elsif cli["start"]
|
39
44
|
workers = YAML.load_file(cli["<config-file>"])["slots"].map do |slot, config|
|
40
45
|
watcher = config["watcher"].constantize.new
|
41
|
-
watcher = Wal::MonitoringWatcher.new(watcher) if config["log_execution_time"]
|
42
46
|
temporary = config["temporary"] || false
|
43
47
|
publications = config["publications"] || []
|
48
|
+
replicator = config["replicator"]&.constantize || Wal::Replicator
|
44
49
|
|
45
50
|
Thread.new(slot, watcher, temporary, publications) do |replication_slot, watcher, use_temporary_slot, publications|
|
46
51
|
replication_slot = "#{replication_slot}_#{SecureRandom.alphanumeric(4)}" if use_temporary_slot
|
47
52
|
puts "Watcher started for #{replication_slot} slot (#{publications.join(", ")})"
|
48
53
|
|
49
|
-
|
50
|
-
.new(replication_slot:, use_temporary_slot:)
|
54
|
+
replicator
|
55
|
+
.new(replication_slot:, use_temporary_slot:, db_config:)
|
51
56
|
.replicate_forever(watcher, publications:)
|
52
57
|
|
53
58
|
puts "Watcher finished for #{replication_slot}"
|
data/lib/wal/version.rb
CHANGED
data/rbi/wal.rbi
CHANGED
@@ -103,7 +103,7 @@ module Wal
|
|
103
103
|
include Wal::Watcher
|
104
104
|
extend T::Sig
|
105
105
|
|
106
|
-
sig { override.params(event: Event).void }
|
106
|
+
sig { override.params(event: Wal::Event).void }
|
107
107
|
def on_event(event); end
|
108
108
|
end
|
109
109
|
|
@@ -113,21 +113,21 @@ module Wal
|
|
113
113
|
include Wal::Watcher
|
114
114
|
extend T::Sig
|
115
115
|
extend T::Helpers
|
116
|
-
RecordEvent = T.type_alias { T.any(InsertEvent, UpdateEvent, DeleteEvent) }
|
116
|
+
RecordEvent = T.type_alias { T.any(Wal::InsertEvent, Wal::UpdateEvent, Wal::DeleteEvent) }
|
117
117
|
|
118
118
|
sig { params(subclass: T.untyped).returns(T.untyped) }
|
119
119
|
def self.inherited(subclass); end
|
120
120
|
|
121
|
-
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), block: T.proc.bind(T.attached_class).params(event: InsertEvent).void).void }
|
121
|
+
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), block: T.proc.bind(T.attached_class).params(event: Wal::InsertEvent).void).void }
|
122
122
|
def self.on_insert(table, &block); end
|
123
123
|
|
124
|
-
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), changed: T.nilable(T::Array[T.any(String, Symbol)]), block: T.proc.bind(T.attached_class).params(event: UpdateEvent).void).void }
|
124
|
+
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), changed: T.nilable(T::Array[T.any(String, Symbol)]), block: T.proc.bind(T.attached_class).params(event: Wal::UpdateEvent).void).void }
|
125
125
|
def self.on_update(table, changed: nil, &block); end
|
126
126
|
|
127
|
-
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), changed: T.nilable(T::Array[T.any(String, Symbol)]), block: T.proc.bind(T.attached_class).params(event: T.any(InsertEvent, UpdateEvent)).void).void }
|
127
|
+
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), changed: T.nilable(T::Array[T.any(String, Symbol)]), block: T.proc.bind(T.attached_class).params(event: T.any(Wal::InsertEvent, Wal::UpdateEvent)).void).void }
|
128
128
|
def self.on_save(table, changed: nil, &block); end
|
129
129
|
|
130
|
-
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), block: T.proc.bind(T.attached_class).params(event: DeleteEvent).void).void }
|
130
|
+
sig { params(table: T.any(String, T.class_of(::ActiveRecord::Base)), block: T.proc.bind(T.attached_class).params(event: Wal::DeleteEvent).void).void }
|
131
131
|
def self.on_destroy(table, &block); end
|
132
132
|
|
133
133
|
sig { params(event: RecordEvent).void }
|
@@ -136,10 +136,10 @@ module Wal
|
|
136
136
|
sig { params(table: String).returns(T::Boolean) }
|
137
137
|
def should_watch_table?(table); end
|
138
138
|
|
139
|
-
sig { params(event: BeginTransactionEvent).returns(Symbol) }
|
139
|
+
sig { params(event: Wal::BeginTransactionEvent).returns(Symbol) }
|
140
140
|
def aggregation_strategy(event); end
|
141
141
|
|
142
|
-
sig { override.params(event: Event).void }
|
142
|
+
sig { override.params(event: Wal::Event).void }
|
143
143
|
def on_event(event); end
|
144
144
|
end
|
145
145
|
|
@@ -150,10 +150,10 @@ module Wal
|
|
150
150
|
sig { params(replication_slot: String, use_temporary_slot: T::Boolean, db_config: T::Hash[Symbol, T.untyped]).void }
|
151
151
|
def initialize(replication_slot:, use_temporary_slot: false, db_config: ActiveRecord::Base.configurations.configs_for(name: "primary").configuration_hash); end
|
152
152
|
|
153
|
-
sig { params(watcher: Watcher, publications: T::Array[String]).void }
|
153
|
+
sig { params(watcher: Wal::Watcher, publications: T::Array[String]).void }
|
154
154
|
def replicate_forever(watcher, publications:); end
|
155
155
|
|
156
|
-
sig { params(watcher: Watcher, publications: T::Array[String]).returns(T::Enumerator::Lazy[Event]) }
|
156
|
+
sig { params(watcher: Wal::Watcher, publications: T::Array[String]).returns(T::Enumerator::Lazy[Wal::Event]) }
|
157
157
|
def replicate(watcher, publications:); end
|
158
158
|
end
|
159
159
|
|
@@ -164,24 +164,23 @@ module Wal
|
|
164
164
|
extend T::Sig
|
165
165
|
extend T::Helpers
|
166
166
|
|
167
|
-
sig { abstract.params(events: T::Enumerator[Event]).void }
|
167
|
+
sig { abstract.params(events: T::Enumerator[Wal::Event]).void }
|
168
168
|
def on_transaction_events(events); end
|
169
169
|
|
170
|
-
sig { params(event: BeginTransactionEvent).returns(Integer) }
|
170
|
+
sig { params(event: Wal::BeginTransactionEvent).returns(Integer) }
|
171
171
|
def queue_size(event); end
|
172
172
|
|
173
|
-
sig { override.params(event: Event).void }
|
173
|
+
sig { override.params(event: Wal::Event).void }
|
174
174
|
def on_event(event); end
|
175
175
|
end
|
176
176
|
|
177
177
|
module Watcher
|
178
178
|
abstract!
|
179
179
|
|
180
|
-
include Wal
|
181
180
|
extend T::Sig
|
182
181
|
extend T::Helpers
|
183
182
|
|
184
|
-
sig { abstract.params(event: Event).void }
|
183
|
+
sig { abstract.params(event: Wal::Event).void }
|
185
184
|
def on_event(event); end
|
186
185
|
|
187
186
|
sig { params(table: String).returns(T::Boolean) }
|
@@ -193,22 +192,22 @@ module Wal
|
|
193
192
|
module SeparatedEvents
|
194
193
|
extend T::Sig
|
195
194
|
|
196
|
-
sig { params(event: Event).void }
|
195
|
+
sig { params(event: Wal::Event).void }
|
197
196
|
def on_event(event); end
|
198
197
|
|
199
|
-
sig { params(event: BeginTransactionEvent).void }
|
198
|
+
sig { params(event: Wal::BeginTransactionEvent).void }
|
200
199
|
def on_begin(event); end
|
201
200
|
|
202
|
-
sig { params(event: InsertEvent).void }
|
201
|
+
sig { params(event: Wal::InsertEvent).void }
|
203
202
|
def on_insert(event); end
|
204
203
|
|
205
|
-
sig { params(event: UpdateEvent).void }
|
204
|
+
sig { params(event: Wal::UpdateEvent).void }
|
206
205
|
def on_update(event); end
|
207
206
|
|
208
|
-
sig { params(event: DeleteEvent).void }
|
207
|
+
sig { params(event: Wal::DeleteEvent).void }
|
209
208
|
def on_delete(event); end
|
210
209
|
|
211
|
-
sig { params(event: CommitTransactionEvent).void }
|
210
|
+
sig { params(event: Wal::CommitTransactionEvent).void }
|
212
211
|
def on_commit(event); end
|
213
212
|
end
|
214
213
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Navarro
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-08-
|
10
|
+
date: 2025-08-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: pg
|