Help us shape the future of Go! Take the 2026 Go Developer Survey

state

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package state provides functionality for storing and retrieving runner state across different environments (local filesystem, Kubernetes, etc.)

Index

Constants

View Source
const (
	// RunConfigsDir is the directory name for storing run configurations
	RunConfigsDir = "runconfigs"

	// GroupConfigsDir is the directory name for storing group configurations
	GroupConfigsDir = "groups"
)
View Source
const (
	// DefaultAppName is the default application name used for XDG paths
	DefaultAppName = "toolhive"

	// FileExtension is the file extension for stored configurations
	FileExtension = ".json"
)

Variables

This section is empty.

Functions

func DeleteSavedRunConfig added in v0.2.4

func DeleteSavedRunConfig(ctx context.Context, name string) error

DeleteSavedRunConfig deletes a saved run configuration

func LoadRunConfigJSON added in v0.2.4

func LoadRunConfigJSON(ctx context.Context, name string) (io.ReadCloser, error)

LoadRunConfigJSON loads a run configuration from the state store and returns the raw reader

Types

type LocalStore

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

LocalStore implements the Store interface using the local filesystem following the XDG Base Directory Specification

func NewLocalStore

func NewLocalStore(appName string, storeName string) (*LocalStore, error)

NewLocalStore creates a new LocalStore with the given application name and store type If appName is empty, DefaultAppName will be used

func (*LocalStore) Delete

func (s *LocalStore) Delete(_ context.Context, name string) error

Delete removes the data for the given name

func (*LocalStore) Exists

func (s *LocalStore) Exists(_ context.Context, name string) (bool, error)

Exists checks if data exists for the given name

func (*LocalStore) GetReader

func (s *LocalStore) GetReader(_ context.Context, name string) (io.ReadCloser, error)

GetReader returns a reader for the state data

func (*LocalStore) GetWriter

func (s *LocalStore) GetWriter(_ context.Context, name string) (io.WriteCloser, error)

GetWriter returns a writer for the state data

func (*LocalStore) List

func (s *LocalStore) List(_ context.Context) ([]string, error)

List returns all available state names

type Store

type Store interface {
	// GetReader returns a reader for the state data
	// This is useful for streaming large state data
	GetReader(ctx context.Context, name string) (io.ReadCloser, error)

	// GetWriter returns a writer for the state data
	// This is useful for streaming large state data
	GetWriter(ctx context.Context, name string) (io.WriteCloser, error)

	// Delete removes the data for the given name
	Delete(ctx context.Context, name string) error

	// List returns all available state names
	List(ctx context.Context) ([]string, error)

	// Exists checks if data exists for the given name
	Exists(ctx context.Context, name string) (bool, error)
}

Store defines the interface for runner state storage operations

func NewGroupConfigStore

func NewGroupConfigStore(appName string) (Store, error)

NewGroupConfigStore creates a store for group configurations

func NewRunConfigStore

func NewRunConfigStore(appName string) (Store, error)

NewRunConfigStore creates a store for run configuration state

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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