Documentation
¶
Overview ¶
Package localstate persists small local JSON documents with explicit commit outcomes at the atomic rename boundary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON returns the exact indented bytes written by ReplaceJSON.
func MarshalJSONCompact ¶
MarshalJSONCompact returns the exact bytes written by ReplaceJSONCompact. Raw JSON payloads retain their accepted byte representation without HTML escaping or presentation whitespace that could exceed their read limits.
Types ¶
type CommitError ¶
type CommitError struct {
Outcome CommitOutcome
Op string
Err error
}
CommitError preserves the truthful outcome when a replacement operation fails. Its text intentionally contains only the operation, never state data.
func (*CommitError) Error ¶
func (e *CommitError) Error() string
func (*CommitError) Unwrap ¶
func (e *CommitError) Unwrap() error
type CommitOutcome ¶
type CommitOutcome string
CommitOutcome identifies whether replacement bytes crossed the atomic rename boundary.
const ( NotCommitted CommitOutcome = "not_committed" Committed CommitOutcome = "committed" CommittedDurabilityUncertain CommitOutcome = "committed_durability_uncertain" )
func RemoveAndSync ¶
func RemoveAndSync(path string) (CommitOutcome, error)
RemoveAndSync removes one local-state file and fsyncs its parent directory. Its outcome identifies whether deletion crossed the filesystem boundary.
func ReplaceJSON ¶
func ReplaceJSON(path string, value any) (CommitOutcome, error)
ReplaceJSON atomically replaces path with one JSON document. Files are mode 0600 and newly created directories are mode 0700.
func ReplaceJSONCompact ¶
func ReplaceJSONCompact(path string, value any) (CommitOutcome, error)
ReplaceJSONCompact atomically replaces path without adding presentation whitespace. It is suitable for stores whose byte bounds include envelopes.
func (CommitOutcome) IsCommitted ¶
func (o CommitOutcome) IsCommitted() bool
IsCommitted reports whether the new bytes were renamed into place.