state

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicate = errors.New("store contains duplicates")
)
View Source
var ErrNoConfig = errors.New("state does not contain config")

Functions

This section is empty.

Types

type Cursor

type Cursor interface {
	Save(state *State, configWriter io.WriterTo) error
	Destroy(id app.ID) error
	Load() (Entries, error)
	Len() (int, error)
}

Cursor provides access to the store

type Entries

type Entries map[app.ID]*State

func Join added in v0.2.6

func Join(s Store) (Entries, error)

Join returns joined state entries of all active aids.

type Joiner added in v0.2.14

type Joiner interface{ Join() (Entries, error) }

Joiner is the interface that wraps the Join method.

The Join function uses Joiner if available.

type State

type State struct {
	// fortify instance id
	ID app.ID `json:"instance"`
	// child process PID value
	PID int `json:"pid"`
	// sealed app configuration
	Config *fst.Config `json:"config"`

	// process start time
	Time time.Time `json:"time"`
}

State is a fortify process's state

type Store

type Store interface {
	// Do calls f exactly once and ensures store exclusivity until f returns.
	// Returns whether f is called and any errors during the locking process.
	// Cursor provided to f becomes invalid as soon as f returns.
	Do(aid int, f func(c Cursor)) (ok bool, err error)

	// List queries the store and returns a list of aids known to the store.
	// Note that some or all returned aids might not have any active apps.
	List() (aids []int, err error)

	// Close releases any resources held by Store.
	Close() error
}

func NewMulti

func NewMulti(runDir string) Store

NewMulti returns an instance of the multi-file store.

Jump to

Keyboard shortcuts

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