class

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)
Source
open(path : Path | String, sync : Bool = true) : Writer

Open a log file for appending, repairing any torn tail first.

Source

Class methods

open(path : Path | String, sync : Bool = true, & : Writer -> ) : Nil
Source
repair(path : Path | String) : Nil

Truncate an uncommitted tail so the log ends at a commit marker.

Source

Instance methods

batch

Append several records under a single commit. The batch is atomic: a tear anywhere inside it discards the whole block.

Source
close
Source
flush
Source
group(name : String, headers : Indexable(String) | Nil = nil) : Nil

Append a group preamble (GS + name) as a committed block.

Source
header(names : Indexable(String)) : Nil

Append an SOH header as a committed block.

Source
header(*names : String) : Nil

Append an SOH header as a committed block.

Source
record(fields : Indexable(String)) : Nil

Append one record as a committed block.

Source
record(*fields : String) : Nil

Append one record as a committed block.

Source
sync

When true and the underlying IO is a File, fsync after each commit.

Source
sync=(sync : Bool)

When true and the underlying IO is a File, fsync after each commit.

Source