Module: Hecks::Adapters::Heki::Journal
- Included in:
- Hecks::Adapters::Heki, SagaStore
- Defined in:
- lib/hecks/adapters/driven/heki/journal.rb
Overview
The append-only journal beside the snapshot: one JSON line per entry, fsynced on append, replayed over the snapshot on read.
Instance Method Summary collapse
Instance Method Details
#entries ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hecks/adapters/driven/heki/journal.rb', line 9 def entries return [] unless File.exist?(@journal_path) File.readlines(@journal_path, chomp: true).reject(&:empty?).map do |line| value = JSON.parse(line) state = value["state"]&.transform_keys(&:to_sym) Ports::Persistence::Entry.new(operation: value.fetch("operation"), id: value.fetch("id"), state: state, mirrors: value["mirrors"]) end end |