def compact

bend-kit-runner@0.13.0.1 · runner.bend:1522

import bend-kit-runner@0.13.0.1/runner.bend as Runner
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import bend-kit-journal@0.3.0.1/journal.bend as J

1522# Writes the state as one Snap record into a new journal, fsyncs it, and renames it over the old one.
1523# A crash leaves one of the two journals, and both replay to this state. After a failure the old
1524# journal stands; when the failure came after the rename, appends stop until the runner is reopened.
1525def compact(~A: Data, ~penc: A -> Bytes.Bytes, r: Runner<A>) -> IO(Ran(A)):
1526  Runner{Log{j, path, limit, base}, +s, p, c, ib, fs} = r
1527  J.Journal{file, +max, end, +ok} = j
1528  do IO<Ran(A)>:
1529    x : Log & Out(Unit) <- compact.if(~A, ~penc, ok, J.Journal{file, max, end, ok}, max, path, limit, base, s)
1530    return compact.done(A, x, s, p, c, ib, fs)

Uses (13)

Used by (1)