state

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 14 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

Package state keeps small records that must outlive a run, such as what each report last posted and when, in memory, in a file, or in AWS SSM Parameter Store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File keeps records in one JSON file. Writes replace the file atomically. It is for a single process; separate processes sharing the file can lose each other's writes.

func NewFile

func NewFile(path string) *File

NewFile creates a store that keeps records in the file at path. The file and its directory are created on the first write.

func (*File) Get

func (f *File) Get(_ context.Context, key string) ([]byte, error)

Get returns the record stored under key, or nil.

func (*File) Put

func (f *File) Put(_ context.Context, key string, value []byte) error

Put stores a record under key.

type Memory

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

Memory keeps records in memory, so they are lost when the process exits.

func NewMemory

func NewMemory() *Memory

NewMemory creates an empty Memory store.

func (*Memory) Get

func (m *Memory) Get(_ context.Context, key string) ([]byte, error)

Get returns the record stored under key, or nil.

func (*Memory) Put

func (m *Memory) Put(_ context.Context, key string, value []byte) error

Put stores a record under key.

type SSM

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

SSM keeps each record in a String parameter named prefix + key. Records are not secret, so they are not encrypted.

func NewSSM

func NewSSM(ctx context.Context, prefix string, client SSMClient) (*SSM, error)

NewSSM creates a store that keeps records under prefix, a path that starts and ends with a slash, such as /github-ops-app/state/. A nil client is created from the default AWS configuration, which makes no network calls.

func (*SSM) Get

func (s *SSM) Get(ctx context.Context, key string) ([]byte, error)

Get returns the record stored under key, or nil.

func (*SSM) Put

func (s *SSM) Put(ctx context.Context, key string, value []byte) error

Put stores a record under key.

type SSMClient

type SSMClient interface {
	GetParameter(ctx context.Context, in *ssm.GetParameterInput, opts ...func(*ssm.Options)) (*ssm.GetParameterOutput, error)
	PutParameter(ctx context.Context, in *ssm.PutParameterInput, opts ...func(*ssm.Options)) (*ssm.PutParameterOutput, error)
}

SSMClient is the part of the SSM API the SSM store uses.

Jump to

Keyboard shortcuts

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