pgoutput-source-adapter 0.0.0 → 0.1.1

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: 9c0d3598bffe622103beb9a3f48c750476dcb06ec81b6d675d3a9b4628d61d1d
4
- data.tar.gz: b4ab4d056f6d9f34620c88d78d28ddc6ccf678463b9975b3e4ad02328d7a61cb
3
+ metadata.gz: ab9b7c87b7ede5dd583ae9457f30fe30fdfcf1dd55b2ca33e08162d23f36601b
4
+ data.tar.gz: 5c7a7b1a081f8a67a07397ecd8034a462e679e636dd2a51d71b9512e90333c85
5
5
  SHA512:
6
- metadata.gz: 80770110f68b77ac080ebd48fe637f8bf7cb3e054e9c9345523535c27f3f8ab35f0c8e4d3ea5387aedbd6bdfc959795556644e2b5a18685c6749dd541ff2b3a7
7
- data.tar.gz: '08b336516e7466179039bbc9a1a8874e96d70d3f9511566ae520e2417a373817ba716bbb20226e606ab532da1f6e00805bdb0da9a025f4d02f1a064bbb1bfdcd'
6
+ metadata.gz: 3a19f060ba7f5552dec37471a114fa4ee30f0c960d20a27c82676f888753c53fe76c4473038170185806dda76988217ab882cf90f5186fdfa28d5dfef438c12a
7
+ data.tar.gz: 00f2d815d0ff8f2d8b9865ecdbee82c528fba3341ecf0125c8f32ddc930365c669bb28ad0cc3c1274c7208089a4eca9ff05bf6d47a9061b234563c92b9c3fd18
data/CHANGELOG.md CHANGED
@@ -1,8 +1,34 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2026-06-08
3
+ ## [0.1.0] - 2026-06-16
4
4
 
5
- - Initial CDC source adapter implementation.
6
- - Added `Pgoutput::SourceAdapter::Cdc`.
7
- - Added normalization from `Pgoutput::Decoder::Events` to `CDC::Core::ChangeEvent`.
8
- - Added transaction batch normalization to `CDC::Core::TransactionEnvelope`.
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
@@ -17,6 +17,7 @@ end
17
17
 
18
18
  YARD::Rake::YardocTask.new(:yard)
19
19
 
20
+ desc 'Validate rbs sig files'
20
21
  task :steep do
21
22
  sh 'bundle exec steep check'
22
23
  end
data/Steepfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Steepfile
4
+ target :lib do
5
+ signature 'sig'
6
+ check 'lib'
7
+
8
+ library 'cdc-core'
9
+ end
@@ -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 = [] # : [Array[CDC::Core::ChangeEvent, CDC::Core::TransactionEnvelope]]
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
 
@@ -5,6 +5,6 @@ module Pgoutput
5
5
  # Current pgoutput-source-adapter gem version.
6
6
  #
7
7
  # @return [String] semantic version published to RubyGems.
8
- VERSION = '0.0.0'
8
+ VERSION = '0.1.1'
9
9
  end
10
10
  end
@@ -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
@@ -0,0 +1,6 @@
1
+ module Pgoutput
2
+ module SourceAdapter
3
+ # Current pgoutput-source-adapter gem version.
4
+ VERSION: String
5
+ end
6
+ 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.0.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken C. Demanawa
@@ -37,8 +37,16 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0.1'
40
- description: Normalizes pgoutput decoded events into downstream change-event platform
41
- primitives, including CDC::Core.
40
+ description: |
41
+ pgoutput-source-adapter provides source adapters that normalize
42
+ decoded PostgreSQL pgoutput events into downstream event models.
43
+
44
+ The gem currently includes a CDC::Core adapter that transforms
45
+ pgoutput decoder events into ChangeEvent and TransactionEnvelope
46
+ primitives while preserving transaction and metadata context.
47
+
48
+ This package forms the normalization boundary between the
49
+ pgoutput family of gems and downstream change-event platforms.
42
50
  email:
43
51
  - kenneth.c.demanawa@gmail.com
44
52
  executables: []
@@ -52,6 +60,7 @@ files:
52
60
  - LICENSE.txt
53
61
  - README.md
54
62
  - Rakefile
63
+ - Steepfile
55
64
  - lib/pgoutput/source/adapter.rb
56
65
  - lib/pgoutput/source_adapter.rb
57
66
  - lib/pgoutput/source_adapter/cdc.rb
@@ -59,6 +68,8 @@ files:
59
68
  - mise.toml
60
69
  - sig/pgoutput/source/adapter.rbs
61
70
  - sig/pgoutput/source_adapter.rbs
71
+ - sig/pgoutput/source_adapter/cdc.rbs
72
+ - sig/pgoutput/source_adapter/version.rbs
62
73
  homepage: https://github.com/kanutocd/pgoutput-source-adapter
63
74
  licenses:
64
75
  - MIT
@@ -84,5 +95,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
95
  requirements: []
85
96
  rubygems_version: 3.6.9
86
97
  specification_version: 4
87
- summary: Source adapters for pgoutput decoded events.
98
+ summary: Source adapters that normalize pgoutput decoded events into downstream change-event
99
+ platforms.
88
100
  test_files: []