wal 0.0.22 → 0.0.24
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 +10 -4
- data/lib/wal/railtie.rb +15 -1
- data/lib/wal/replicator.rb +3 -0
- data/lib/wal/version.rb +1 -1
- data/lib/wal.rb +4 -0
- 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: dbc63f98019737c35c19d3dab2f5d3d51018f00cc242489ce49fda0d9678b2e6
|
|
4
|
+
data.tar.gz: 22f30e0b6e380a90fc898b279a4badc03fc04183c8d01df12ba8cf851844fb52
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c8a14e8cc979763892ffbfdf3e2988ca1f90fa3185b5a78e689c5149fc5eda74a2ef128530b6616f6a2f5559c6df3529334c45f0080728fca0776656d61570c
|
|
7
|
+
data.tar.gz: ae98a50cffa3399d122012f15088274af73752aff7744481402d141e07e12b686294e7a004c61a799cade16f1cab2cf077fde1402124b3ec0760dd51ee62514f
|
data/exe/wal
CHANGED
|
@@ -91,7 +91,10 @@ elsif cli["start"]
|
|
|
91
91
|
temporary = config["temporary"] || false
|
|
92
92
|
publications = config["publications"] || []
|
|
93
93
|
replicator_class = config["replicator"].presence&.constantize || Wal::Replicator
|
|
94
|
-
|
|
94
|
+
max_retries = config["retries"]&.to_i || (2**32 - 1)
|
|
95
|
+
retries = 0
|
|
96
|
+
backoff = config["retry_backoff"]&.to_f || 1
|
|
97
|
+
backoff_expoent = config["retry_backoff_expoent"]&.to_f
|
|
95
98
|
|
|
96
99
|
Thread.new(slot, watcher, temporary, publications) do |replication_slot, watcher, use_temporary_slot, publications|
|
|
97
100
|
replication_slot = "#{replication_slot}_#{SecureRandom.alphanumeric(4)}" if use_temporary_slot
|
|
@@ -103,10 +106,13 @@ elsif cli["start"]
|
|
|
103
106
|
begin
|
|
104
107
|
replicator.replicate_forever(watcher, publications:)
|
|
105
108
|
rescue StandardError => err
|
|
106
|
-
if retries
|
|
109
|
+
if retries < max_retries
|
|
107
110
|
Wal.logger&.error("[#{replication_slot}] Error #{err}")
|
|
108
|
-
retries
|
|
109
|
-
|
|
111
|
+
retries += 1
|
|
112
|
+
backoff_time = backoff_expoent ? (backoff * retries) ** backoff_expoent : backoff
|
|
113
|
+
puts "Restarting #{replication_slot} in #{backoff_time.floor(2)}s..."
|
|
114
|
+
sleep backoff_time
|
|
115
|
+
puts "Restarting #{replication_slot}"
|
|
110
116
|
retry
|
|
111
117
|
end
|
|
112
118
|
raise
|
data/lib/wal/railtie.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "rails/railtie"
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module Wal
|
|
6
6
|
class Railtie < Rails::Railtie
|
|
7
7
|
generators do
|
|
8
8
|
require_relative "generators/migration"
|
|
@@ -13,5 +13,19 @@ module Waldit
|
|
|
13
13
|
ActiveRecord::Migration.include Wal::Migration
|
|
14
14
|
ActiveRecord::Schema.include Wal::Migration
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
config.after_initialize do
|
|
18
|
+
# "Borrowed" from Sidekiq
|
|
19
|
+
# https://github.com/sidekiq/sidekiq/blob/61e27d20b1ed62f203eee6ae2b549f2e53db14c9/lib/sidekiq/rails.rb#L38-L58
|
|
20
|
+
unless Rails.logger == Wal.logger || ActiveSupport::Logger.logger_outputs_to?(Rails.logger, $stdout)
|
|
21
|
+
if Rails.logger.respond_to?(:broadcast_to)
|
|
22
|
+
Rails.logger.broadcast_to(Wal.logger)
|
|
23
|
+
elsif ActiveSupport::Logger.respond_to?(:broadcast)
|
|
24
|
+
Rails.logger.extend(ActiveSupport::Logger.broadcast(Wal.logger))
|
|
25
|
+
else
|
|
26
|
+
Rails.logger = ActiveSupport::BroadcastLogger.new(Rails.logger, Wal.logger)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
16
30
|
end
|
|
17
31
|
end
|
data/lib/wal/replicator.rb
CHANGED
data/lib/wal/version.rb
CHANGED
data/lib/wal.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.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rodrigo Navarro
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: pg
|