Documentation
¶
Overview ¶
Package atomicfile writes small state files the way lerd's daemons need: atomically, and only when the content actually changed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteIfChanged ¶
WriteIfChanged writes data to path via a unique temp file, an fsync and a rename, so a reader never sees a half-written file and a crash never loses a published one, and skips the write entirely when path already holds exactly these bytes.
The skip is the point. A daemon that re-persists a snapshot on a fixed tick spends a write, a rename and a dirtied page every tick even when nothing happened, which on a laptop keeps the disk and the writeback path from ever settling. Comparing against what is already there costs one read of a small, page-cached file. Reports whether it wrote.
Types ¶
This section is empty.