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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7cd3acf2bcf902cb1bbc73a89063a6f360b73bacb52e4764900ece3eaa5e08d
4
- data.tar.gz: 67cf46933f34837e0d7b9730ff87cee2e785e4057adb9fa519f1e80150513a88
3
+ metadata.gz: dbc63f98019737c35c19d3dab2f5d3d51018f00cc242489ce49fda0d9678b2e6
4
+ data.tar.gz: 22f30e0b6e380a90fc898b279a4badc03fc04183c8d01df12ba8cf851844fb52
5
5
  SHA512:
6
- metadata.gz: a8ecd8b4dde1dfb4867c6532da43714d53662482b86f8a76b5adda396edba042d46cd1d1bdb2ed86590efbfb3f29c8946b37094621176c19690b738939affa97
7
- data.tar.gz: ccb32bab9c54f998451f3b10ff1a0895ac06b07f6446ae8aafeb24cc32c10bca2672622790276ac9895b26ca9616a061fad359cf8ac7ac9835366138b248f091
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
- retries = config["retries"]&.to_i || 5
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 > 0
109
+ if retries < max_retries
107
110
  Wal.logger&.error("[#{replication_slot}] Error #{err}")
108
- retries -= 1
109
- sleep 2 ** retries
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 Waldit
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
@@ -155,6 +155,9 @@ module Wal
155
155
  else
156
156
  next
157
157
  end
158
+ rescue
159
+ watch_conn&.close
160
+ raise
158
161
  end
159
162
  end
160
163
 
data/lib/wal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wal
4
- VERSION = "0.0.22"
4
+ VERSION = "0.0.24"
5
5
  end
data/lib/wal.rb CHANGED
@@ -14,6 +14,10 @@ require_relative "wal/version"
14
14
  module Wal
15
15
  class << self
16
16
  attr_accessor :logger
17
+
18
+ def logger
19
+ @logger ||= Logger.new($stdout, level: :info)
20
+ end
17
21
  end
18
22
 
19
23
  def self.configure(&block)
data/rbi/wal.rbi CHANGED
@@ -7,7 +7,7 @@ module Wal
7
7
  UpdateEvent,
8
8
  DeleteEvent,
9
9
  ) }
10
- VERSION = "0.0.21"
10
+ VERSION = "0.0.24"
11
11
 
12
12
  class << self
13
13
  sig { returns(T.class_of(Logger)) }
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.22
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: 2025-10-21 00:00:00.000000000 Z
10
+ date: 2026-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: pg