waldit 0.0.23 → 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/lib/waldit/context.rb +1 -1
- data/lib/waldit/railtie.rb +1 -0
- data/lib/waldit/record.rb +2 -2
- data/lib/waldit/version.rb +1 -1
- data/lib/waldit/watcher.rb +23 -21
- data/rbi/waldit.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: ef4aa2e9ecc05e8ecbb7c56e55230023a75d89c3e3daafece6159ccdf5f4c397
|
|
4
|
+
data.tar.gz: 1bebe39aa54aebb419b0aa7803bd921841078eccc587b68bf74d09954599b774
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 408d31b50109b258f60df794ed72619c969115cf0823505f7c5341453b60d2f176fd97a8b17722d24996cdaecf9d30f63ff5da55ecd67a96b17426dcccb61075
|
|
7
|
+
data.tar.gz: 26a0a32bb8fb94029479097f969eb72cbe1e70514e027c06dc07efb459f5fefe6b273fcc2d3de5bf2e35ef8705d5714b11d0ef118422caef69313e1e01a3b998
|
data/lib/waldit/context.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Waldit
|
|
4
4
|
module Context
|
|
5
|
-
def with_context(context, &block)
|
|
5
|
+
def with_context(context = {}, &block)
|
|
6
6
|
current_context = self.context || {}
|
|
7
7
|
Thread.current[:waldit_context] ||= []
|
|
8
8
|
Thread.current[:waldit_context].push(current_context.merge(context.as_json))
|
data/lib/waldit/railtie.rb
CHANGED
data/lib/waldit/record.rb
CHANGED
|
@@ -4,10 +4,10 @@ module Waldit
|
|
|
4
4
|
module Record
|
|
5
5
|
def self.included(base)
|
|
6
6
|
base.class_eval do
|
|
7
|
-
scope :from_table, -> table { order(:committed_at).where(table_name: table) }
|
|
7
|
+
scope :from_table, -> table { order(:committed_at, :lsn).where(table_name: table) }
|
|
8
8
|
scope :from_model, -> model { from_table(model.table_name) }
|
|
9
9
|
scope :for, -> record { from_model(record.class).where(primary_key: record.id) }
|
|
10
|
-
scope :with_context, -> ctx { order(:committed_at).where("context @> ?", ctx.to_json) }
|
|
10
|
+
scope :with_context, -> ctx { order(:committed_at, :lsn).where("context @> ?", ctx.to_json) }
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
data/lib/waldit/version.rb
CHANGED
data/lib/waldit/watcher.rb
CHANGED
|
@@ -49,27 +49,29 @@ module Waldit
|
|
|
49
49
|
events.each do |event|
|
|
50
50
|
case event
|
|
51
51
|
when CommitTransactionEvent
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
unless tables.empty?
|
|
53
|
+
changes = [:old, :new, :diff]
|
|
54
|
+
.map { |diff| [diff, tables.filter { |table| Waldit.store_changes.call(table).include? diff }] }
|
|
55
|
+
.to_h
|
|
56
|
+
|
|
57
|
+
log_new = (changes[:new] || []).map { |table| "#{table}" }
|
|
58
|
+
log_old = (changes[:old] || []).map { |table| "#{table}" }
|
|
59
|
+
log_diff = (changes[:diff] || []).map { |table| "#{table}" }
|
|
60
|
+
|
|
61
|
+
@connection.exec_prepared("waldit_finish", [
|
|
62
|
+
event.transaction_id,
|
|
63
|
+
event.timestamp,
|
|
64
|
+
"{#{log_new.join(",")}}",
|
|
65
|
+
"{#{log_old.join(",")}}",
|
|
66
|
+
"{#{log_diff.join(",")}}",
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
@connection.exec_prepared("waldit_cleanup", [
|
|
70
|
+
event.transaction_id,
|
|
71
|
+
"{#{(log_new + log_old).join(",")}}",
|
|
72
|
+
"{#{log_diff.join(",")}}",
|
|
73
|
+
])
|
|
74
|
+
end
|
|
73
75
|
|
|
74
76
|
# We sucessful retried a connection, let's reset our retry state
|
|
75
77
|
@retry = false
|
data/rbi/waldit.rbi
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: waldit
|
|
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: 2026-
|
|
10
|
+
date: 2026-02-11 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: wal
|