store

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 10 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 store owns the on-disk task state file and the rules for changing it. The daemon holds one Store; daemonless CLI writers go through the same Apply path so the file never sees interleaved writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir returns the sideline state directory. SIDELINE_STATE_DIR wins, then XDG_STATE_HOME, then the default under HOME.

func Load

func Load(path string) (*model.State, error)

Load reads the state file at path. A missing file yields a fresh empty state, so a first run needs no special casing.

func LockPath

func LockPath(path string) string

LockPath returns the flock file guarding the state file at path.

func Save

func Save(path string, s *model.State) error

Save writes s to path atomically: a temp file in the same directory, fsync, then rename. A failure anywhere leaves the previous file intact.

func SocketPath

func SocketPath() string

SocketPath returns the default daemon socket path.

func StateFile

func StateFile() string

StateFile returns the default state file path.

func Watch

func Watch(path string) (<-chan *model.State, func(), error)

Watch reports the state loaded from path after every change to it, including Save's atomic rename (a Create event on the path). The stop func ends the watch; the channel is closed after stop.

Types

type Store

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

Store is the owner of the state file at Path. All mutations go through Apply, which serialises in-process callers and takes an exclusive flock so daemonless writers in other processes cannot interleave.

func New

func New(path string) (*Store, error)

New returns a store for the state file at path, loading the current contents when the file exists.

func (*Store) Apply

func (s *Store) Apply(req model.Request) (model.Response, error)

Apply applies one request to the state and persists the result. On success the response carries the new state; on failure the file is untouched.

func (*Store) BumpReload

func (s *Store) BumpReload() error

BumpReload increments the reload counter and persists it. Renderers watch the state file, so this is the signal that asks them to re-read the config.

func (*Store) Path

func (s *Store) Path() string

Path returns the state file path, for reload messages.

func (*Store) State

func (s *Store) State() *model.State

State returns a deep copy of the current state.

Jump to

Keyboard shortcuts

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