Skip to main content

Module atomic

Module atomic 

Source
Expand description

Atomic write helpers (create-tempfile-then-rename) for projection files.

Functions§

open_events_append
Open events.jsonl for O_APPEND writes (creating it if absent).
write_atomic
Write bytes to path atomically: tempfile in the same directory, then rename, then a parent-directory fsync. The tempfile is fsynced before the rename. Creates the parent directory if absent.
write_atomic_no_create
Like write_atomic but does NOT create the parent directory: if the parent is absent the write fails with the underlying NotFound error instead of resurrecting it. Used for writes that must never recreate a directory deleted out from under the writer — e.g. the supervisor’s per-tick state save once its run dir has vanished (otherwise the create_dir_all would rebuild the run dir ghost-file by ghost-file).
write_json_atomic
JSON-pretty-serialize value and atomically write to path.
write_json_atomic_no_create
Like write_json_atomic but does NOT create the parent directory. See write_atomic_no_create.