Class: Pgoutput::BinaryParser
- Inherits:
-
Object
- Object
- Pgoutput::BinaryParser
- Defined in:
- lib/pgoutput/binary_parser.rb
Overview
Offset-based binary parser for one PostgreSQL pgoutput logical replication message payload.
A parser instance is intentionally short-lived and mutable while reading a single payload. Its returned message object is deeply frozen/shareable and may cross Ractor boundaries safely.
rubocop:disable Metrics/ClassLength
Instance Method Summary collapse
-
#initialize(payload) ⇒ void
constructor
Initializes parser state for the supplied payload.
-
#parse ⇒ Pgoutput::Messages::Begin, ...
Parse one supported pgoutput message.
Constructor Details
#initialize(payload) ⇒ void
Returns initializes parser state for the supplied payload.
16 17 18 19 |
# File 'lib/pgoutput/binary_parser.rb', line 16 def initialize(payload) @payload = payload.b @offset = 0 end |
Instance Method Details
#parse ⇒ Pgoutput::Messages::Begin, ...
Parse one supported pgoutput message.
Supported MVP tags are ‘B`, `M`, `O`, `R`, `Y`, `I`, `U`, `D`, `T`, and `C`.
rubocop:disable Metrics/CyclomaticComplexity
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pgoutput/binary_parser.rb', line 34 def parse case read_byte_chr when "B" then parse_begin when "M" then when "O" then parse_origin when "R" then parse_relation when "Y" then parse_type when "I" then parse_insert when "U" then parse_update when "D" then parse_delete when "T" then parse_truncate when "C" then parse_commit else raise UnsupportedMessageError, "unsupported pgoutput message tag" end end |