Documentation
¶
Overview ¶
Package atomicio writes a file atomically (temp + rename) and keeps a single rollback backup. It is the shared swap discipline used for the cached abuse.ch feed snapshots (and is the same temp+rename pattern the rules cache uses), so a concurrent reader never sees a half-written file and a bad write can roll back.
Index ¶
Constants ¶
const BackupSuffix = ".bak"
BackupSuffix is appended to keep exactly one previous copy.
Variables ¶
This section is empty.
Functions ¶
func ReadCached ¶
ReadCached reads path, returning the bytes and true when a non-empty file exists, or (nil, false) otherwise — the warm-start read for a cached feed.
func WriteWithBackup ¶
WriteWithBackup writes data to path atomically: it writes a temp file in the same directory, fsyncs it, backs up any existing file to path+".bak", then renames the temp file into place (same-filesystem rename is atomic). The parent directory is created if missing. On any error the original file is left untouched.
Types ¶
This section is empty.