class
C0::Stream::Writer
- C0::Stream::Writer
- Reference
- Object
Overview
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.
Defined in:
c0/stream.crConstructors
- .new(io : IO, sync : Bool = false)
-
.open(path : Path | String, sync : Bool = true) : Writer
Open a log file for appending, repairing any torn tail first.
Class Method Summary
- .open(path : Path | String, sync : Bool = true, & : Writer -> ) : Nil
-
.repair(path : Path | String) : Nil
Truncate an uncommitted tail so the log ends at a commit marker.
Instance Method Summary
-
#batch(& : Builder -> ) : Nil
Append several records under a single commit.
- #close : Nil
- #flush : Nil
-
#group(name : String, headers : Indexable(String) | Nil = nil) : Nil
Append a group preamble (GS + name) as a committed block.
-
#header(names : Indexable(String)) : Nil
Append an SOH header as a committed block.
-
#header(*names : String) : Nil
Append an SOH header as a committed block.
-
#record(fields : Indexable(String)) : Nil
Append one record as a committed block.
-
#record(*fields : String) : Nil
Append one record as a committed block.
-
#sync : Bool
When true and the underlying IO is a File, fsync after each commit.
-
#sync=(sync : Bool)
When true and the underlying IO is a File, fsync after each commit.
Constructor Detail
Open a log file for appending, repairing any torn tail first.
Class Method Detail
Truncate an uncommitted tail so the log ends at a commit marker.
Instance Method Detail
Append several records under a single commit. The batch is atomic: a tear anywhere inside it discards the whole block.
Append a group preamble (GS + name) as a committed block.