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

state

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: May 9, 2025 License: Apache-2.0 Imports: 7 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 (
	// DefaultAppName is the default application name used for XDG paths
	DefaultAppName = "toolhive"

	// RunConfigsDir is the directory name for storing run configurations
	RunConfigsDir = "runconfigs"

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

Variables

This section is empty.

Functions

This section is empty.

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) (*LocalStore, error)

NewLocalStore creates a new LocalStore with the given application name 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

func (*LocalStore) Load

func (s *LocalStore) Load(_ context.Context, name string, w io.Writer) error

Load retrieves the data for the given name and writes it to the provided writer

func (*LocalStore) Save

func (s *LocalStore) Save(_ context.Context, name string, r io.Reader) error

Save stores the data for the given name from the provided reader

type Store

type Store interface {
	// Save stores the data for the given name from the provided reader
	Save(ctx context.Context, name string, r io.Reader) error

	// Load retrieves the data for the given name and writes it to the provided writer
	// Returns an error if the state doesn't exist
	Load(ctx context.Context, name string, w io.Writer) error

	// 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 NewStore

func NewStore(appName string) (Store, error)

NewStore creates a new state store For now, only the local store is implemented

Jump to

Keyboard shortcuts

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