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 ¶
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"`
}
Click to show internal directories.
Click to hide internal directories.