statefile

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 13 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 statefile owns private atomic files and recoverable local commits.

Index

Constants

View Source
const (
	Settings = "settings"
)

Variables

This section is empty.

Functions

func ReadSettings

func ReadSettings(ctx context.Context, path string) ([]byte, error)

ReadSettings needs no writable directory in the ordinary sharing path. A pending multi-file commit is recovered first; otherwise atomic replacement guarantees that a concurrent writer exposes either complete settings version.

func Remove

func Remove(path string) error

func StateDirectory

func StateDirectory(path string) string

func Transact

func Transact(ctx context.Context, path string, action func(*Transaction) error) error

func WithLock

func WithLock(ctx context.Context, path string, action func() error) error

func Write

func Write(ctx context.Context, path string, data []byte) (err error)

Types

type Transaction

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

Transaction coordinates settings and operation records in one local namespace. Optional discovery caches do not participate in these commits.

func (*Transaction) Delete

func (tx *Transaction) Delete(name string) error

func (*Transaction) Operations

func (tx *Transaction) Operations() ([]string, error)

func (*Transaction) Put

func (tx *Transaction) Put(name string, data []byte) error

func (*Transaction) Read

func (tx *Transaction) Read(name string) ([]byte, error)

func (*Transaction) SettingsPath

func (tx *Transaction) SettingsPath() string

SettingsPath lets configuration errors identify the same file held by the transaction.

Jump to

Keyboard shortcuts

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