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

pods

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package pods saves and loads named, versioned whole-emulator snapshots ("pods") to a local directory or an S3-compatible bucket.

Index

Constants

View Source
const Format = "gopherstack-pod/v1"

Format identifies the pod archive layout.

Variables

View Source
var (
	// ErrInvalidName is returned for pod names that are unsafe as storage keys.
	ErrInvalidName = errors.New("invalid pod name")
	// ErrCorrupt is returned when a stored pod archive cannot be read.
	ErrCorrupt = errors.New("pod archive is corrupt")
	// ErrBucketRequired is returned when an S3 store is configured without a bucket.
	ErrBucketRequired = errors.New("pods: s3 bucket is required")
)
View Source
var ErrNotFound = errors.New("pod not found")

ErrNotFound is returned when a pod, version or blob does not exist.

Functions

func MergeScoped

func MergeScoped(current, incoming []byte) ([]byte, bool, error)

MergeScoped merges the incoming service snapshot into current per account/region: records in an account/region present in incoming replace current's records for that scope, other scopes in current are kept. scoped is false when incoming has no account/region records; the caller must then replace the whole service state.

func ValidName

func ValidName(name string) bool

ValidName reports whether name is a legal pod name.

Types

type BlobStore

type BlobStore interface {
	Put(ctx context.Context, key string, data []byte) error
	Get(ctx context.Context, key string) ([]byte, error)
	// List returns every key that starts with prefix, sorted.
	List(ctx context.Context, prefix string) ([]string, error)
	Delete(ctx context.Context, key string) error
}

BlobStore is the minimal object storage pods need. Keys use "/" separators.

type DirStore

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

DirStore stores blobs as files under a root directory.

func NewDirStore

func NewDirStore(dir string) (*DirStore, error)

NewDirStore returns a DirStore rooted at dir, creating it if needed.

func (*DirStore) Delete

func (d *DirStore) Delete(_ context.Context, key string) error

Delete removes a blob; a missing blob is not an error.

func (*DirStore) Get

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

Get reads a blob.

func (*DirStore) List

func (d *DirStore) List(_ context.Context, prefix string) ([]string, error)

List returns keys under root that start with prefix.

func (*DirStore) Put

func (d *DirStore) Put(_ context.Context, key string, data []byte) error

Put writes data atomically (temp file + rename).

type Manifest

type Manifest struct {
	CreatedAt time.Time `json:"createdAt"`
	Name      string    `json:"name"`
	Format    string    `json:"format"`
	Message   string    `json:"message,omitempty"`
	Services  []string  `json:"services"`
	Version   int       `json:"version"`
	Size      int64     `json:"size"`
}

Manifest describes one saved pod version.

type S3Config

type S3Config struct {
	Bucket    string
	Prefix    string
	Endpoint  string
	Region    string
	AccessKey string
	SecretKey string
	PathStyle bool
}

S3Config configures an S3-compatible remote. Endpoint may point at real AWS S3 (leave empty), another S3-compatible server, or Gopherstack itself.

type S3Store

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

S3Store stores blobs as S3 objects under Prefix.

func NewS3Store

func NewS3Store(ctx context.Context, cfg S3Config) (*S3Store, error)

NewS3Store builds an S3-backed BlobStore. Without explicit keys the default AWS credential chain is used.

func (*S3Store) Delete

func (s *S3Store) Delete(ctx context.Context, key string) error

Delete removes an object.

func (*S3Store) Get

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

Get downloads a blob.

func (*S3Store) List

func (s *S3Store) List(ctx context.Context, prefix string) ([]string, error)

List returns keys (relative to Prefix) that start with prefix.

func (*S3Store) Put

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

Put uploads data.

type Service

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

Service implements pod operations over a BlobStore.

func New

func New(store BlobStore) *Service

New returns a Service backed by store.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, name string, version int) error

Delete removes one version, or the whole pod when version is 0.

func (*Service) Inspect

func (s *Service) Inspect(ctx context.Context, name string, version int) (Manifest, error)

Inspect returns the manifest of a version (0 = latest).

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Summary, error)

List summarises every pod in the store.

func (*Service) Load

func (s *Service) Load(
	ctx context.Context, name string, version int, services []string,
) (Manifest, map[string][]byte, error)

Load returns the manifest and per-service snapshots of a version (0 = latest). When services is non-empty only those services are returned.

func (*Service) Save

func (s *Service) Save(ctx context.Context, name, message string, snaps map[string][]byte) (Manifest, error)

Save stores snaps (service name to raw snapshot) as the next version of pod name.

func (*Service) Versions

func (s *Service) Versions(ctx context.Context, name string) ([]Manifest, error)

Versions lists all manifests of a pod, oldest first.

type Summary

type Summary struct {
	LatestAt time.Time `json:"latestAt"`
	Name     string    `json:"name"`
	Versions int       `json:"versions"`
	Latest   int       `json:"latest"`
}

Summary is one entry of the pod listing.

Jump to

Keyboard shortcuts

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