pgoutput-source-adapter 0.0.0 → 0.1.0
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/CHANGELOG.md +31 -5
- data/Rakefile +1 -0
- data/Steepfile +9 -0
- data/lib/pgoutput/source_adapter/cdc.rb +13 -3
- data/lib/pgoutput/source_adapter/version.rb +1 -1
- data/sig/pgoutput/source_adapter/cdc.rbs +81 -0
- data/sig/pgoutput/source_adapter/version.rbs +6 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b2fb472b0d96fc532dd1fc6f1f4dfae6cc9938975379509ebf96966ad885eb55
|
|
4
|
+
data.tar.gz: 24bf3dcfa578a525de9269f14652f1f12c688231f7a6656bfbc5534e48d8dd4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 220075b2c70a17079e6b56a65735d491539196c8bc2fa0adf631cadf955d5f52080cf1efef4498a40f5478a71fb087b5e9b7a4fbe000238db1c3d61e8f3aa8bf
|
|
7
|
+
data.tar.gz: ec89c4a27b1ac3eab75d4376e827f64dc423370b633780b663d3ac0615e036273b1cc2237790363922aa9d280c12c76dfcf6ce54a961c8dd47d9f8264d7b1eb8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
-
## [0.1.0] - 2026-06-
|
|
3
|
+
## [0.1.0] - 2026-06-16
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Initial release of pgoutput-source-adapter.
|
|
8
|
+
- CDC::Core source adapter implementation.
|
|
9
|
+
- Normalization of decoded pgoutput Insert events into CDC::Core::ChangeEvent.
|
|
10
|
+
- Normalization of decoded pgoutput Update events into CDC::Core::ChangeEvent.
|
|
11
|
+
- Normalization of decoded pgoutput Delete events into CDC::Core::ChangeEvent.
|
|
12
|
+
- Normalization of transaction boundaries into CDC::Core::TransactionEnvelope.
|
|
13
|
+
- Configurable primary key resolution.
|
|
14
|
+
- Configurable metadata generation.
|
|
15
|
+
- Namespace compatibility aliases.
|
|
16
|
+
|
|
17
|
+
### Documentation
|
|
18
|
+
|
|
19
|
+
- Expanded YARD documentation.
|
|
20
|
+
- Added architecture and usage examples.
|
|
21
|
+
- Improved API documentation coverage.
|
|
22
|
+
- Added descriptions for public YARD tags.
|
|
23
|
+
|
|
24
|
+
### Quality
|
|
25
|
+
|
|
26
|
+
- Added comprehensive unit tests.
|
|
27
|
+
- Added SimpleCov line and branch coverage reporting.
|
|
28
|
+
- Added Steep type checking support.
|
|
29
|
+
- Added RuboCop integration.
|
|
30
|
+
|
|
31
|
+
### Coverage
|
|
32
|
+
|
|
33
|
+
- Line Coverage: 97.62%
|
|
34
|
+
- Branch Coverage: 91.18%
|
data/Rakefile
CHANGED
data/Steepfile
ADDED
|
@@ -49,6 +49,7 @@ module Pgoutput
|
|
|
49
49
|
# nil for transaction boundary events.
|
|
50
50
|
# @raise [Pgoutput::SourceAdapter::Error] when the decoded event type is
|
|
51
51
|
# unsupported.
|
|
52
|
+
# rubocop:disable Metrics/MethodLength
|
|
52
53
|
def normalize(event)
|
|
53
54
|
case event_name(event)
|
|
54
55
|
when 'Insert'
|
|
@@ -85,6 +86,7 @@ module Pgoutput
|
|
|
85
86
|
raise Error, "unsupported pgoutput decoded event: #{event.class}"
|
|
86
87
|
end
|
|
87
88
|
end
|
|
89
|
+
# rubocop:enable Metrics/MethodLength
|
|
88
90
|
|
|
89
91
|
# Normalize a sequence of decoded pgoutput events.
|
|
90
92
|
#
|
|
@@ -97,11 +99,15 @@ module Pgoutput
|
|
|
97
99
|
# normalized row changes and transaction envelopes in input order.
|
|
98
100
|
# @raise [Pgoutput::SourceAdapter::Error] when any decoded event type is
|
|
99
101
|
# unsupported.
|
|
102
|
+
# rubocop:disable Metrics/AbcSize
|
|
103
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
104
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
|
105
|
+
# rubocop:disable Metrics/MethodLength
|
|
100
106
|
def normalize_many(events)
|
|
101
|
-
results = [] # :
|
|
107
|
+
results = [] # : Array[CDC::Core::ChangeEvent | CDC::Core::TransactionEnvelope]
|
|
102
108
|
transaction_id = nil
|
|
103
|
-
transaction_events = []
|
|
104
|
-
transaction_metadata = {}
|
|
109
|
+
transaction_events = [] # : Array[CDC::Core::ChangeEvent]
|
|
110
|
+
transaction_metadata = {} # : Hash[String, untyped]
|
|
105
111
|
|
|
106
112
|
events.each do |event|
|
|
107
113
|
case event_name(event)
|
|
@@ -140,6 +146,10 @@ module Pgoutput
|
|
|
140
146
|
results.concat(transaction_events) if transaction_id && !transaction_events.empty?
|
|
141
147
|
share(results.freeze)
|
|
142
148
|
end
|
|
149
|
+
# rubocop:enable Metrics/AbcSize
|
|
150
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
151
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
|
152
|
+
# rubocop:enable Metrics/MethodLength
|
|
143
153
|
|
|
144
154
|
private
|
|
145
155
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module Pgoutput
|
|
2
|
+
module SourceAdapter
|
|
3
|
+
# Normalizes Pgoutput::Decoder::Events into CDC::Core primitives.
|
|
4
|
+
#
|
|
5
|
+
# This adapter is intentionally located under the Pgoutput namespace because
|
|
6
|
+
# it adapts pgoutput decoded events. The target is CDC::Core, so this class
|
|
7
|
+
# depends on cdc-core while the lower-level pgoutput-client, pgoutput-parser,
|
|
8
|
+
# and pgoutput-decoder gems remain standalone.
|
|
9
|
+
#
|
|
10
|
+
# @example Normalize a decoded insert event
|
|
11
|
+
# adapter = Pgoutput::SourceAdapter::Cdc.new
|
|
12
|
+
# change_event = adapter.normalize(decoded_insert)
|
|
13
|
+
#
|
|
14
|
+
# @example Normalize a decoded transaction event batch
|
|
15
|
+
# envelope = adapter.normalize_many([begin_event, insert_event, commit_event]).first
|
|
16
|
+
#
|
|
17
|
+
# @api public
|
|
18
|
+
class Cdc < CDC::Core::SourceAdapter
|
|
19
|
+
@primary_key_resolver: untyped
|
|
20
|
+
|
|
21
|
+
@metadata_builder: untyped
|
|
22
|
+
|
|
23
|
+
SOURCE_NAME: "pgoutput"
|
|
24
|
+
|
|
25
|
+
# @param primary_key_resolver [#call, nil] optional callable used to infer
|
|
26
|
+
# primary keys from decoded row values when pgoutput does not provide an
|
|
27
|
+
# old-key tuple.
|
|
28
|
+
# @param metadata_builder [#call, nil] optional callable that can return
|
|
29
|
+
# extra metadata for each decoded event.
|
|
30
|
+
def initialize: (?primary_key_resolver: untyped?, ?metadata_builder: untyped?) -> void
|
|
31
|
+
|
|
32
|
+
# Normalize one decoded pgoutput event.
|
|
33
|
+
#
|
|
34
|
+
# Transaction boundary events return nil because they do not represent a
|
|
35
|
+
# row-level change by themselves. Use #normalize_many when transaction
|
|
36
|
+
# envelopes are desired.
|
|
37
|
+
#
|
|
38
|
+
# @param event [Object] a Pgoutput::Decoder::Events object.
|
|
39
|
+
# @return [CDC::Core::ChangeEvent, nil]
|
|
40
|
+
def normalize: (untyped event) -> untyped
|
|
41
|
+
|
|
42
|
+
# Normalize a sequence of decoded pgoutput events.
|
|
43
|
+
#
|
|
44
|
+
# If the sequence contains transaction boundaries, row changes between a
|
|
45
|
+
# Begin and Commit are grouped into CDC::Core::TransactionEnvelope. If no
|
|
46
|
+
# transaction boundaries are present, row changes are returned individually.
|
|
47
|
+
#
|
|
48
|
+
# @param events [Enumerable<Object>] decoded pgoutput events.
|
|
49
|
+
# @return [Array<CDC::Core::ChangeEvent, CDC::Core::TransactionEnvelope>]
|
|
50
|
+
def normalize_many: (untyped events) -> untyped
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
attr_reader primary_key_resolver: untyped
|
|
55
|
+
|
|
56
|
+
attr_reader metadata_builder: untyped
|
|
57
|
+
|
|
58
|
+
def change_event: (untyped event, operation: untyped, old_values: untyped, new_values: untyped, primary_key: untyped) -> untyped
|
|
59
|
+
|
|
60
|
+
def transaction_envelope: (untyped event, transaction_id: untyped, events: untyped, metadata: untyped) -> untyped
|
|
61
|
+
|
|
62
|
+
def primary_key_for: (untyped event, untyped values) -> untyped
|
|
63
|
+
|
|
64
|
+
def default_primary_key: (untyped _event, untyped values) -> (nil | untyped)
|
|
65
|
+
|
|
66
|
+
def metadata_for: (untyped event) -> untyped
|
|
67
|
+
|
|
68
|
+
def relation_id_for: (untyped event) -> (untyped | nil)
|
|
69
|
+
|
|
70
|
+
def event_name: (untyped event) -> untyped
|
|
71
|
+
|
|
72
|
+
def lsn_string: (untyped lsn) -> untyped
|
|
73
|
+
|
|
74
|
+
def stringify_keys: (untyped hash) -> untyped
|
|
75
|
+
|
|
76
|
+
def compact: (untyped hash) -> untyped
|
|
77
|
+
|
|
78
|
+
def share: (untyped object) -> untyped
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgoutput-source-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ken C. Demanawa
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- LICENSE.txt
|
|
53
53
|
- README.md
|
|
54
54
|
- Rakefile
|
|
55
|
+
- Steepfile
|
|
55
56
|
- lib/pgoutput/source/adapter.rb
|
|
56
57
|
- lib/pgoutput/source_adapter.rb
|
|
57
58
|
- lib/pgoutput/source_adapter/cdc.rb
|
|
@@ -59,6 +60,8 @@ files:
|
|
|
59
60
|
- mise.toml
|
|
60
61
|
- sig/pgoutput/source/adapter.rbs
|
|
61
62
|
- sig/pgoutput/source_adapter.rbs
|
|
63
|
+
- sig/pgoutput/source_adapter/cdc.rbs
|
|
64
|
+
- sig/pgoutput/source_adapter/version.rbs
|
|
62
65
|
homepage: https://github.com/kanutocd/pgoutput-source-adapter
|
|
63
66
|
licenses:
|
|
64
67
|
- MIT
|