store

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package store defines the persistence interfaces and model types for storing Kubernetes resource revisions as snapshots and patches.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = errors.New("not found")
	ErrInvalidRevision = errors.New("invalid revision")
)

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
}

Codec is an interface for encoding and decoding data.

var DefaultCodec Codec = &pooledMsgpackCodec{}

DefaultCodec is a pooled MessagePack codec that reuses encoder/decoder objects and their underlying buffers across calls.

type Patch

type Patch struct {
	// ID is the revision identifier for this patch.
	ID RevisionID `msgpack:"i" json:"ID,omitempty"`
	// PreviousID is the ID of the previous revision.
	// This should always be set since a patch cannot exist without a previous snapshot.
	PreviousID RevisionID `msgpack:"<,omitempty" json:"previousID,omitempty"`

	// Patch is the diff between the previous revision and this revision.
	// See [diffmap.Diff] for more details.
	Patch diffmap.DiffMap `msgpack:"s" json:"patch,omitempty"`
	Time  time.Time       `msgpack:"t" json:"time"`
}

type ResourcePatchStore

type ResourcePatchStore interface {
	Get(ctx context.Context, objectID string, revID RevisionID) (*Snapshot, *Patch, error)

	SetSnapshot(ctx context.Context, objectID string, snap *Snapshot) error
	SetPatch(ctx context.Context, objectID string, p *Patch) error

	GetLatestRevision(ctx context.Context, objectID string) (RevisionID, error)
	WalkObjectRevisions(yield func(string, RevisionID, *Snapshot, *Patch) bool) error
	Close() error
}

ResourcePatchStore is an interface for storing and retrieving resource patches and snapshots.

type RevisionID

type RevisionID uint64

func (RevisionID) String

func (id RevisionID) String() string

type Snapshot

type Snapshot struct {
	// ID is the revision identifier for this snapshot.
	ID RevisionID `msgpack:"i" json:"ID,omitempty"`
	// PreviousID is the ID of the previous revision. This can be empty if this is the first revision.
	PreviousID RevisionID `msgpack:"<,omitempty" json:"previousID,omitempty"`

	// Object is the full resource state stored in this revision.
	Object diffmap.DiffMap `msgpack:"o" json:"object,omitempty"`
	Time   time.Time       `msgpack:"t" json:"time"`
}

Directories

Path Synopsis
Package bbolt implements store.ResourcePatchStore backed by a BoltDB database file.
Package bbolt implements store.ResourcePatchStore backed by a BoltDB database file.

Jump to

Keyboard shortcuts

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