durable

package
v0.9.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package durable flushes a write that has already returned.

Three packages needed the same two operations -- flush a file the process is no longer holding open, and flush the directory a rename or a create just changed -- and each had written its own copy of them. The copies agreed, which is what made them dangerous: both operations rest on POSIX semantics that Windows does not share, so the same defect had to be found and fixed three times, and the reason for the difference had nowhere to live.

It lives here. What a caller gets is the strongest flush the platform can give for that path, and a comment saying where that is weaker than a POSIX fsync.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Directory

func Directory(path string) error

Directory flushes the directory entry a rename or a create just changed.

Writing a file durably is two operations on POSIX, not one: the file's own fsync persists its contents, and the parent directory's persists the name that reaches them. A crash between the two leaves a file that is complete and unreachable, which is precisely the state the generation store spends its rollback paths avoiding.

func File

func File(path string) error

File flushes a file the caller is no longer holding open.

It opens for reading *and* writing even though it writes nothing. On POSIX an fsync is legal on a descriptor opened read-only, and every version of this that reached for os.Open worked there; Windows resolves the same call to FlushFileBuffers, which needs a handle with write access and answers ERROR_ACCESS_DENIED without one. Asking for the access the flush needs costs nothing on the platform that did not require it.

The consequence for a caller is that a file it cannot write, it cannot flush, which is honest: a read-only file has nothing of the caller's left in the operating system's buffers to lose.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL