persistence

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package persistence owns application-write accounting and atomic publication. It leaves flushing to the kernel; successful publication is not a power-loss guarantee.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicFile

func AtomicFile(path, pattern string, data []byte, counter *Counter) error

AtomicFile closes a private same-directory temporary file before rename. A failed publication still accounts bytes successfully written to its temp file.

Types

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

Counter is invocation-owned, never global or restored as a lifetime total.

func (*Counter) Snapshot

func (c *Counter) Snapshot() *Snapshot

func (*Counter) Writer

func (c *Counter) Writer(w io.Writer) io.Writer

Writer counts the returned byte count even when the write also reports an error. Wrap the file, not a buffer: buffered bytes have not yet reached the kernel.

type Snapshot

type Snapshot struct {
	Bytes uint64 `json:"bytes"`
	Scope string `json:"scope"`
}

Snapshot describes instrumented application writes, not physical device I/O.

Jump to

Keyboard shortcuts

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