appstate

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 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

internal/appstate/lock.go

Package appstate centralises all filesystem state access for the Omniview application, providing a single source of truth for the state directory root.

internal/appstate/scoped.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveRoot

func ResolveRoot() (string, error)

ResolveRoot determines the application state directory. Priority: OMNIVIEW_STATE_DIR env var > buildStateDir ldflags > ~/.omniview. Exported for use by secondary binaries (e.g., cmd/omniview-plugin-dev).

Types

type Option

type Option func(*config)

Option configures the Service constructor.

func WithFlock

func WithFlock(enabled bool) Option

WithFlock enables or disables file locking.

func WithRoot

func WithRoot(path string) Option

WithRoot sets the root directory for the state service.

type ScopedRoot

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

ScopedRoot provides contained filesystem access to a subdirectory. All path arguments are relative to the scope root. The underlying os.Root enforces containment at the kernel level.

func (*ScopedRoot) Close

func (s *ScopedRoot) Close() error

Close releases the underlying os.Root handle.

func (*ScopedRoot) FS

func (s *ScopedRoot) FS() fs.FS

func (*ScopedRoot) MkdirAll

func (s *ScopedRoot) MkdirAll(path string, perm fs.FileMode) error

func (*ScopedRoot) OpenFile

func (s *ScopedRoot) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)

func (*ScopedRoot) ReadDir

func (s *ScopedRoot) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the named directory relative to the scoped root. Implemented as Open + (*File).ReadDir since os.Root does not expose ReadDir.

func (*ScopedRoot) ReadFile

func (s *ScopedRoot) ReadFile(name string) ([]byte, error)

func (*ScopedRoot) Remove

func (s *ScopedRoot) Remove(name string) error

func (*ScopedRoot) RemoveAll

func (s *ScopedRoot) RemoveAll(name string) error

func (*ScopedRoot) Rename

func (s *ScopedRoot) Rename(oldpath, newpath string) error

func (*ScopedRoot) ResolvePath

func (s *ScopedRoot) ResolvePath(name string) string

ResolvePath returns the absolute path for a relative name within the scoped root. If name is empty, the root path itself is returned. If name fails validation (e.g. absolute path or traversal), the root path is returned as a safe fallback.

func (*ScopedRoot) Stat

func (s *ScopedRoot) Stat(name string) (fs.FileInfo, error)

func (*ScopedRoot) WriteFile

func (s *ScopedRoot) WriteFile(name string, data []byte, perm fs.FileMode) error

type Service

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

Service is the central authority for all application state filesystem access. Create once at startup via New() and inject into subsystems.

func New

func New(opts ...Option) (*Service, error)

New creates a new Service with the given options.

func NewTestService

func NewTestService(t testing.TB) *Service

NewTestService creates a Service backed by a temporary directory for use in tests. The service is automatically cleaned up when the test finishes.

func (*Service) Close

func (s *Service) Close() error

Close releases all resources held by the Service. Errors from individual close operations are aggregated and returned together. Close is idempotent; subsequent calls return the result of the first call.

func (*Service) Logs

func (s *Service) Logs() *ScopedRoot

Logs returns the scoped root for the logs directory.

func (*Service) PluginData

func (s *Service) PluginData(id string) (*ScopedRoot, error)

PluginData returns a scoped root for a specific plugin's data directory. The result is cached; subsequent calls for the same id return the cached instance.

func (*Service) PluginStore

func (s *Service) PluginStore(id string) (*ScopedRoot, error)

PluginStore returns a scoped root for a specific plugin's store directory. The result is cached; subsequent calls for the same id return the cached instance.

func (*Service) Plugins

func (s *Service) Plugins() *ScopedRoot

Plugins returns the scoped root for the plugins directory.

func (*Service) Root

func (s *Service) Root() string

Root returns the absolute path to the state directory.

func (*Service) RootDir

func (s *Service) RootDir() *ScopedRoot

RootDir returns the scoped root for the top-level state directory.

Jump to

Keyboard shortcuts

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