C0::Stream::Writer
Inherits Reference / Object
Appends ETB-committed blocks to an append-only log.
C0::Stream::Writer.open("claims.c0") do |log| log.record("create", nonce, ts) log.batch do |b| b.record("name", label, ts) b.record("tag", tags, ts) end end
Each block and its ETB are issued as a single write. open repairs
a torn tail (truncates to the last commit) before appending.
Constructors
new(io : IO, sync : Bool = false)
Sourceopen(path : Path | String, sync : Bool = true) : Writer
Open a log file for appending, repairing any torn tail first.
Class methods
open(path : Path | String, sync : Bool = true, & : Writer -> ) : Nil
Sourcerepair(path : Path | String) : Nil
Truncate an uncommitted tail so the log ends at a commit marker.
Instance methods
batch
Append several records under a single commit. The batch is atomic: a tear anywhere inside it discards the whole block.
close
Sourceflush
Sourcegroup(name : String, headers : Indexable(String) | Nil = nil) : Nil
Append a group preamble (GS + name) as a committed block.