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

workload

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 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")
	ErrEngineNotReady      = errors.New("the database's engine is not ready")
)

The failures a run's record names by reason (Decisions 4, 5; ADR-0234 Decision 2).

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/, and a SQLDatabase's SQLite file to sql/<name>/ in records of 8 MiB keyed 000001, 000002, … (ADR-0234 Decision 2). 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, CatalogServices then SQLDatabases: by name, the stores of the App's kv, buckets, catalogs and sql 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
	SQL          func(ctx context.Context, ns v1.NamespaceName, name v1.ObjectName) (io.ReadCloser, error)
}

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, and a database's SQLite file from its engine (ADR-0234; nil ⇒ no SQL members), which fails ErrEngineNotReady for a database with no Ready engine and returns the stream's error, not io.EOF, when the engine reports one at its end.

Jump to

Keyboard shortcuts

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