save

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package save contains streaming, crash-safe document persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atomic

func Atomic(path string, mode os.FileMode, prefix []byte, writeContent func(io.Writer) (int64, error)) (int64, error)

Atomic streams content into a same-directory temporary file, flushes it, and atomically replaces path. The caller supplies an immutable document snapshot.

func AtomicChecked

func AtomicChecked(path string, mode os.FileMode, prefix []byte, writeContent func(io.Writer) (int64, error), beforeReplace func() error) (int64, error)

AtomicChecked performs a final conflict check after the potentially long stream write and immediately before replacing the original file.

func SyncParent added in v0.3.0

func SyncParent(path string) error

SyncParent retries durability of the directory entry containing path. It is a no-op on platforms whose replacement primitive already provides the required guarantee.

Types

type DurabilityError added in v0.3.0

type DurabilityError struct {
	Path string
	Err  error
}

DurabilityError means the target name was atomically replaced, but the platform could not confirm that the directory entry is durable across a power loss. Callers must treat the content as committed.

func (*DurabilityError) Committed added in v0.3.0

func (e *DurabilityError) Committed() bool

func (*DurabilityError) Error added in v0.3.0

func (e *DurabilityError) Error() string

func (*DurabilityError) Unwrap added in v0.3.0

func (e *DurabilityError) Unwrap() error

Jump to

Keyboard shortcuts

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