Class: Igniter::Store::Codecs::JsonCrc32
- Inherits:
-
Object
- Object
- Igniter::Store::Codecs::JsonCrc32
- Includes:
- WireProtocol
- Defined in:
- lib/igniter/store/codecs.rb
Overview
── JsonCrc32 ───────────────────────────────────────────────────────────
One CRC32-framed JSON frame per fact. Matches the pure-Ruby FileBackend format — readable without any extra dependencies.
Constant Summary collapse
- NAME =
"json_crc32"
Constants included from WireProtocol
WireProtocol::FRAME_CRC_SIZE, WireProtocol::FRAME_HEADER_SIZE
Instance Method Summary collapse
- #buffered_count ⇒ Object
- #decode(io) ⇒ Object
- #encode_fact(io, fact) ⇒ Object
-
#flush(_io) ⇒ Object
stateless, nothing buffered.
- #name ⇒ Object
-
#start_segment(_io, store: nil) ⇒ Object
no header needed.
Methods included from WireProtocol
Instance Method Details
#buffered_count ⇒ Object
63 |
# File 'lib/igniter/store/codecs.rb', line 63 def buffered_count = 0 |
#decode(io) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/igniter/store/codecs.rb', line 65 def decode(io) facts = [] loop do body = read_frame(io) break unless body fact = Fact.from_h(JSON.parse(body, symbolize_names: true)) rescue nil facts << fact if fact end facts end |
#encode_fact(io, fact) ⇒ Object
56 57 58 59 |
# File 'lib/igniter/store/codecs.rb', line 56 def encode_fact(io, fact) frame = encode_frame(JSON.generate(fact.to_h)) io.write(frame) end |
#flush(_io) ⇒ Object
stateless, nothing buffered
61 |
# File 'lib/igniter/store/codecs.rb', line 61 def flush(_io) = 0 # stateless, nothing buffered |
#name ⇒ Object
52 |
# File 'lib/igniter/store/codecs.rb', line 52 def name = NAME |
#start_segment(_io, store: nil) ⇒ Object
no header needed
54 |
# File 'lib/igniter/store/codecs.rb', line 54 def start_segment(_io, store: nil) = 0 # no header needed |