workload

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package workload is an app owner's backup (ADR-0222): the members a BackupSchedule's scope names, one full copy of them under <target>/<ns>/<backup>-<uid>/ (Decision 4) and the reads a Restore makes of it. Each member's file is ADR-0203's framed records in one Seal stream, put in 8 MiB parts IfNotExist; a catalog's objects go before its catalog.db, checked against it (Decision 5); the plain manifest.yaml goes last.

Index

Constants

View Source
const Format = 1

Format is the workload manifest's format; a changed meaning, framing or layout bumps it.

Variables

View Source
var (
	ErrCatalogUnstable     = errors.New("the catalog changed under every copy")
	ErrTargetUnconditional = errors.New("the target refuses a create-if-absent put")
)

The failures a run's record names by reason (Decisions 4, 5).

Functions

func CatalogFiles

func CatalogFiles(db []byte) ([]string, error)

CatalogFiles lists the objects a DuckLake checkpoint names (Decision 5): each ducklake_data_file and ducklake_delete_file path, resolved against its table's, its schema's and the data path, as a key relative to the data path, the catalog's prefix; sorted and distinct. It reads a read-only temporary copy of db. A path outside the data path is fault.Invalid: a restore into another prefix could not follow it.

func DecodeObject

func DecodeObject(v []byte) (contentType string, md map[string]string, body []byte, err error)

DecodeObject reverses EncodeObject; a torn or trailing frame is fault.Invalid.

func EncodeObject

func EncodeObject(contentType string, md map[string]string, body []byte) []byte

EncodeObject frames an object as uvarint-length fields (ADR-0203): its content type, its metadata's count and each key and value in key order, then its body.

func Integrity

func Integrity(ctx context.Context, src blob.Bucket, path string, m Manifest) error

Integrity reads every part of every file m names and checks its bytes and sha256; a missing part or a mismatch is fault.Invalid.

func KVPrefix

func KVPrefix(ns v1.NamespaceName, name v1.ObjectName) string

KVPrefix is a KVStore's key prefix in the KV substrate, <ns>/<store>/ (ADR-0072).

func Records

func Records(ctx context.Context, src blob.Bucket, path string, f backup.StoreFile, open backup.Unseal) func() (snapshot.Record, error)

Records reads f's records through open: io.EOF at the end, a torn record fault.Invalid.

Types

type Manifest

type Manifest struct {
	Format     int          `json:"format"`
	Namespace  string       `json:"namespace"`
	Backup     string       `json:"backup"`
	Funcd      string       `json:"funcd"`
	At         v1.Timestamp `json:"at"`
	Members    []MemberFile `json:"members"`
	Recipients []string     `json:"recipients,omitempty"`
}

Manifest is a Backup's manifest.yaml, plain, written last: the copy exists once it does. Backup is the copy's directory, <backup>-<uid>.

func ReadManifest

func ReadManifest(ctx context.Context, src blob.Bucket, path string) (Manifest, error)

ReadManifest reads the manifest under path; a format above Format is fault.Invalid.

func Write

func Write(ctx context.Context, ns v1.NamespaceName, ms []Member, src Sources, o Options) (Manifest, error)

Write copies ms under o.Path, then puts the manifest (Decisions 4, 5): a KVStore to kv/<store>/, a Bucket's objects to blob/<bucket>/, a catalog's objects but catalog.db to catalog/<name>/<attempt>/files/ and then its catalog.db to catalog/<name>/<attempt>/catalog.db/. A refused IfNotExist is ErrTargetUnconditional; a catalog whose checkpoint names an object no attempt copied is ErrCatalogUnstable.

type Member

type Member struct {
	Kind    v1.Kind
	Name    v1.ObjectName
	Catalog v1.CatalogRef
}

Member is one store of a scope. Catalog is a CatalogService member's spec.catalog, which Write copies.

func Resolve

func Resolve(ctx context.Context, st store.Store, ns v1.NamespaceName, s v1.BackupScope) ([]Member, error)

Resolve lists the members s names in ns (Decision 2), KVStores, Buckets then CatalogServices: by name, the stores of the App's kv, buckets and catalogs entries, or the stores of the ResourceGroup. A named member or App that does not exist is fault.NotFound naming it.

type MemberFile

type MemberFile struct {
	Kind    v1.Kind            `json:"kind"`
	Name    v1.ObjectName      `json:"name"`
	Attempt int                `json:"attempt,omitempty"`
	Files   []backup.StoreFile `json:"files"`
}

MemberFile is one member's files in the manifest: a store's one, a catalog's files then catalog.db, of Attempt.

type Options

type Options struct {
	Target     blob.Bucket
	Path       string
	Seal       backup.Seal
	Recipients []string
}

Options are where Write puts the copy and to whom it seals it: Path is <ns>/<backup>-<uid>/ on Target, Recipients the fingerprints the manifest records.

type Sources

type Sources struct {
	KV           func(prefix string) snapshot.Source
	Blob         blob.Bucket
	BucketPrefix func(ns v1.NamespaceName, b v1.ObjectName) string
}

Sources are what Write reads: the KV driver's per-store export (ADR-0209 SnapshotPrefix; nil when the driver offers none), the shared blob store and a Bucket's prefix in it.

Jump to

Keyboard shortcuts

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