wal 0.0.24 → 0.0.25
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 +45 -35
- data/lib/wal/version.rb +1 -1
- data/rbi/wal.rbi +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: 7ff2f0a5d9392268db27728b053f29ac897649314c72b857b0d43303bb8face1
|
|
4
|
+
data.tar.gz: a378a4d4c4e5f3f1e6d9a988fe61947683c52614223e27a67371b4042434a2cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5514c83c92062744f25cdc2f7f08aaa79cdbd4bc7cd49c6028de964f3d5c02a0a0b8d2d3b8f3a6cdf69954adb45f5a89866f5fdd193cebfd1cb1fc24049d3ba9
|
|
7
|
+
data.tar.gz: a29bb6e5c5cc9795e82d88d15f4e820cc88b651f58950c67120dc988454aa6230d0e85af25e016289402c5bb5a6b1db9341e039fdc350155a86710190be6bad2
|
data/exe/wal
CHANGED
|
@@ -69,7 +69,7 @@ class Wal::LoggingReplicator
|
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
def watch(db_config, cli)
|
|
73
73
|
watcher = cli["--watcher"].constantize.new
|
|
74
74
|
use_temporary_slot = cli["--tmp-slot"] || false
|
|
75
75
|
replication_slot = cli["--slot"]
|
|
@@ -82,46 +82,50 @@ if cli["watch"]
|
|
|
82
82
|
replicator = Wal::LoggingReplicator.new(replication_slot, replicator)
|
|
83
83
|
replicator.replicate_forever(watcher, publications:)
|
|
84
84
|
puts "Watcher finished for #{replication_slot}"
|
|
85
|
+
end
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
puts "Watcher started for #{replication_slot} slot (#{publications.join(", ")})"
|
|
102
|
-
|
|
87
|
+
def start_worker(db_config, slot, config)
|
|
88
|
+
watcher = config["watcher"].constantize.new
|
|
89
|
+
temporary = config["temporary"] || false
|
|
90
|
+
publications = config["publications"] || []
|
|
91
|
+
replicator_class = config["replicator"].presence&.constantize || Wal::Replicator
|
|
92
|
+
max_retries = config["retries"]&.to_i || (2**32 - 1)
|
|
93
|
+
retries = 0
|
|
94
|
+
backoff = config["retry_backoff"]&.to_f || 1
|
|
95
|
+
backoff_expoent = config["retry_backoff_expoent"]&.to_f
|
|
96
|
+
|
|
97
|
+
Thread.new(slot, watcher, temporary, publications) do |replication_slot, watcher, use_temporary_slot, publications|
|
|
98
|
+
replication_slot = "#{replication_slot}_#{SecureRandom.alphanumeric(4)}" if use_temporary_slot
|
|
99
|
+
puts "Watcher started for #{replication_slot} slot (#{publications.join(", ")})"
|
|
100
|
+
|
|
101
|
+
begin
|
|
103
102
|
replicator = replicator_class.new(replication_slot:, use_temporary_slot:, db_config:)
|
|
104
103
|
replicator = Wal::LoggingReplicator.new(replication_slot, replicator)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
puts "Restarting #{replication_slot}"
|
|
116
|
-
retry
|
|
117
|
-
end
|
|
118
|
-
raise
|
|
104
|
+
replicator.replicate_forever(watcher, publications:)
|
|
105
|
+
rescue StandardError => err
|
|
106
|
+
if retries < max_retries
|
|
107
|
+
Wal.logger&.error("[#{replication_slot}] Error #{err}")
|
|
108
|
+
retries += 1
|
|
109
|
+
backoff_time = backoff_expoent ? (backoff * retries) ** backoff_expoent : backoff
|
|
110
|
+
puts "Restarting #{replication_slot} in #{backoff_time.floor(2)}s..."
|
|
111
|
+
sleep backoff_time
|
|
112
|
+
puts "Restarting #{replication_slot}"
|
|
113
|
+
retry
|
|
119
114
|
end
|
|
115
|
+
raise
|
|
116
|
+
end
|
|
120
117
|
|
|
121
|
-
|
|
118
|
+
puts "Watcher finished for #{replication_slot}"
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
Process.kill("TERM", Process.pid)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def start(db_config, cli)
|
|
125
|
+
slots = YAML.load_file(cli["<config-file>"])["slots"]
|
|
126
|
+
|
|
127
|
+
workers = slots.map do |slot, config|
|
|
128
|
+
start_worker(db_config, slot, config)
|
|
125
129
|
end
|
|
126
130
|
|
|
127
131
|
ping = Thread.new do
|
|
@@ -147,3 +151,9 @@ elsif cli["start"]
|
|
|
147
151
|
|
|
148
152
|
workers.each(&:join)
|
|
149
153
|
end
|
|
154
|
+
|
|
155
|
+
if cli["watch"]
|
|
156
|
+
watch(db_config, cli)
|
|
157
|
+
elsif cli["start"]
|
|
158
|
+
start(db_config, cli)
|
|
159
|
+
end
|
data/lib/wal/version.rb
CHANGED
data/rbi/wal.rbi
CHANGED
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.25
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rodrigo Navarro
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-01-
|
|
10
|
+
date: 2026-01-12 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: pg
|