envstore

package
v0.0.0-...-10bf2d1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLiveSession               = errors.New("environment has a live session")
	ErrSessionStateIndeterminate = errors.New("environment session state is indeterminate")
)
View Source
var ErrEnvironmentNotFound = errors.New("environment not found")

Functions

func DefaultRoot

func DefaultRoot(home string) string

func EnsureNoLiveSessions

func EnsureNoLiveSessions(stateDir string) error

EnsureNoLiveSessions fails closed: a proven live session blocks removal, and malformed/unreadable state also blocks removal because it is not proof of staleness.

func ReapStaleSessions

func ReapStaleSessions(stateDir string) (int, error)

ReapStaleSessions removes only markers whose PID is gone or whose process start identity no longer matches. Indeterminate markers are preserved and returned as an error for diagnostics.

func WriteSessionMetadata

func WriteSessionMetadata(sessionDir string, metadata SessionMetadata) error

Types

type Environment

type Environment struct {
	Dir      string
	Manifest config.Manifest
}

type EnvironmentNotFoundError

type EnvironmentNotFoundError struct{ Name string }

func (*EnvironmentNotFoundError) Error

func (e *EnvironmentNotFoundError) Error() string

func (*EnvironmentNotFoundError) Is

func (e *EnvironmentNotFoundError) Is(target error) bool

type Health

type Health struct {
	Status    string    `json:"status"`
	CheckedAt time.Time `json:"checked_at"`
	Warnings  int       `json:"warnings"`
	Errors    int       `json:"errors"`
}

type ListIssue

type ListIssue struct {
	Name string
	Err  error
}

type Session

type Session struct {
	Dir      string
	Kind     string
	Metadata SessionMetadata
	Status   SessionStatus
	Err      error
}

func InspectSessions

func InspectSessions(stateDir string) ([]Session, error)

InspectSessions examines both interactive shell and exec-style session markers. Malformed or unreadable metadata is indeterminate, never stale.

type SessionMetadata

type SessionMetadata struct {
	Schema       int       `json:"schema"`
	PID          int       `json:"pid"`
	ProcessStart string    `json:"process_start"`
	CreatedAt    time.Time `json:"created_at"`
}

func NewSessionMetadata

func NewSessionMetadata() (SessionMetadata, error)

NewSessionMetadata records the same PID/start-time identity used by advisory lock metadata, so PID reuse cannot make an abandoned session look live.

func NewSessionMetadataForPID

func NewSessionMetadataForPID(pid int) (SessionMetadata, error)

type SessionStatus

type SessionStatus string
const (
	SessionLive          SessionStatus = "live"
	SessionStale         SessionStatus = "stale"
	SessionIndeterminate SessionStatus = "indeterminate"
)

type Store

type Store struct {
	Root string
	Home string
}

func FromProcess

func FromProcess() (Store, error)

func (Store) BundlesDir

func (s Store) BundlesDir() string

func (Store) CheckAvailableName

func (s Store) CheckAvailableName(name string) error

func (Store) Create

func (s Store) Create(manifest config.Manifest) (Environment, error)

func (Store) Ensure

func (s Store) Ensure() (config.GlobalConfig, error)

func (Store) EnvDir

func (s Store) EnvDir(name string) string

func (Store) EnvironmentNames

func (s Store) EnvironmentNames() ([]string, error)

func (Store) EnvsDir

func (s Store) EnvsDir() string

func (Store) List

func (s Store) List(strict bool) ([]Environment, error)

func (Store) ListWithIssues

func (s Store) ListWithIssues(strict bool) ([]Environment, []ListIssue, error)

ListWithIssues returns every loadable environment and reports corrupt entries independently so one damaged manifest does not hide unrelated environments.

func (Store) Load

func (s Store) Load(name string, strict bool) (Environment, error)

func (Store) LocksDir

func (s Store) LocksDir() string

func (Store) LogsDir

func (s Store) LogsDir() string

func (Store) ManifestPath

func (s Store) ManifestPath(name string) string

func (Store) Publish

func (s Store) Publish(staged Environment) (Environment, error)

func (Store) ReadHealth

func (s Store) ReadHealth(env Environment) Health

func (Store) Remove

func (s Store) Remove(name, importID string) (string, error)

func (Store) Save

func (s Store) Save(env Environment) error

func (Store) SaveStaged

func (s Store) SaveStaged(env Environment) error

func (Store) Stage

func (s Store) Stage(manifest config.Manifest) (Environment, error)

func (Store) TrashDir

func (s Store) TrashDir() string

Jump to

Keyboard shortcuts

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