store

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store keeps strata's index in a local DuckDB file.

The index is a rebuildable cache of what the registry holds, with one exception: tag history, which the registry cannot give back. It can be exported to and imported from Parquet so it survives a rebuild.

Index

Constants

View Source
const FormatVersion = 1

FormatVersion is the version of strata's table layout. It is recorded in the file's meta table, and Open refuses a file written by a newer strata.

Variables

This section is empty.

Functions

func CreateTempLike added in v0.2.1

func CreateTempLike(ctx context.Context, conn *sql.Conn, temp, like string) error

CreateTempLike creates (or replaces) an empty temporary table named temp with the columns and types of table like, declared explicitly.

It does not use CREATE TABLE ... AS SELECT ... LIMIT 0. In DuckDB 2.0, a table created that way inside a transaction and then filled past one row group (122,880 rows) is invisible to semi-joins and EXCEPT until the transaction commits, so a diff against it silently comes out empty. TestCreateTempLikeLarge guards against this.

func Stage added in v0.2.1

func Stage(ctx context.Context, conn *sql.Conn, temp, like string, rows func(a *duckdb.Appender) error) error

Stage creates a temporary table named temp with like's columns and bulk-loads it through the appender. Callers compare staged rows with stored ones and write the difference.

Types

type Batch

type Batch struct {
	Images     []*model.Image
	Index      []model.IndexEntry
	Tags       []model.Tag
	DeleteTags []model.Tag
	Events     []model.TagEvent
	Referrers  []model.Referrer
	// Pushes are push and pull times reported by the registry's API. They
	// change between crawls, so they replace what was stored.
	Pushes []model.Push
	// BaseRefs are the bases builds say images started from.
	BaseRefs []model.BaseRef
	// ProvenanceChecked are index digests whose provenance was read, so a
	// backfill skips them.
	ProvenanceChecked []string
	// Run and Done checkpoint repos of a crawl run in the same
	// transaction as their data, so a resumed crawl never skips a repo
	// whose rows were lost.
	Run  int64
	Done []string
}

Batch is a set of records written together in one transaction.

func (*Batch) Len

func (b *Batch) Len() int

Len returns the number of records in the batch.

type Store

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

Store is an open index file.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open opens or creates the index at path, creating the schema and checking the format version. An empty path opens a private in-memory index.

func (*Store) CheckpointRepo

func (s *Store) CheckpointRepo(ctx context.Context, run int64, repo string) error

CheckpointRepo records that a crawl run finished a repo.

func (*Store) Close

func (s *Store) Close() error

Close closes the index.

func (*Store) DB

func (s *Store) DB() *sql.DB

DB returns the underlying database handle for read queries.

func (*Store) ExportHistory

func (s *Store) ExportHistory(ctx context.Context, path string) (int64, error)

ExportHistory writes tag history to a Parquet file.

func (*Store) FinishCrawl

func (s *Store) FinishCrawl(ctx context.Context, run int64) error

FinishCrawl marks a crawl run complete.

func (*Store) ImportHistory

func (s *Store) ImportHistory(ctx context.Context, path string) (int64, error)

ImportHistory merges tag history from a Parquet file written by ExportHistory, keeping rows already present.

func (*Store) KnownDigests

func (s *Store) KnownDigests(ctx context.Context, repo string) (map[string]bool, error)

KnownDigests returns the manifest and index digests already indexed for a repo, so a re-crawl only fetches what is new.

func (*Store) KnownImage

func (s *Store) KnownImage(ctx context.Context, digest string) (bool, error)

KnownImage reports whether a manifest digest is indexed in any repo.

func (*Store) MergeRows added in v0.2.1

func (s *Store) MergeRows(ctx context.Context, table, scope string, scopeArgs []any, keys []string, rows [][]any) (int, error)

MergeRows makes the rows of table that match scope equal to rows, in one transaction. It bulk-loads rows into a staging table and writes only the differences: rows to remove, and rows to add or change, matched on the key columns. Rewriting rows that did not change is what makes a delete-and-reload slow on a table with a primary key. It returns how many rows it removed or wrote.

func (*Store) Meta

func (s *Store) Meta(ctx context.Context, key string) (string, error)

Meta returns a value from the meta table, or "" if it is not set.

func (*Store) MissingBases added in v0.3.1

func (s *Store) MissingBases(ctx context.Context, retryAfter time.Time) ([]model.BaseRef, error)

MissingBases returns the bases builds named, by digest, that are not indexed and were not tried since retryAfter.

func (*Store) Path

func (s *Store) Path() string

Path returns the file the index lives in, or "" for an in-memory index.

func (*Store) RecordBaseFetch added in v0.3.1

func (s *Store) RecordBaseFetch(ctx context.Context, r model.BaseRef, errText string, at time.Time) error

RecordBaseFetch records an attempt to fetch a base by digest; errText is empty when it succeeded.

func (*Store) SetMeta

func (s *Store) SetMeta(ctx context.Context, key, value string) error

SetMeta stores a value in the meta table.

func (*Store) StartCrawl

func (s *Store) StartCrawl(ctx context.Context, registry string) (int64, map[string]bool, error)

StartCrawl returns the crawl run to work on for a registry: the last one if it never finished, so a crash resumes, or a new one. It also returns the repos the run already finished.

func (*Store) Tags

func (s *Store) Tags(ctx context.Context, repo string) (map[string]string, error)

Tags returns where each tag of a repo pointed at the last crawl.

func (*Store) UncheckedIndexes added in v0.3.1

func (s *Store) UncheckedIndexes(ctx context.Context, host string, limit int) ([]UncheckedIndex, error)

UncheckedIndexes returns up to limit indexes in repos under host whose provenance was never read, as for images indexed before strata read provenance.

func (*Store) Write

func (s *Store) Write(ctx context.Context, b *Batch) error

Write stores a batch in one transaction, bulk-loading through DuckDB's appender. Images are content-addressed, so an image already in the index is left as it is.

type UncheckedIndex added in v0.3.1

type UncheckedIndex struct {
	Repo   string
	Digest string
}

UncheckedIndex is a multi-platform index whose provenance was never read, and a repo holding it.

Jump to

Keyboard shortcuts

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