layerpack

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 19 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported = errors.New("layerpack: entry cannot be stored in a tree")
	ErrChanged     = errors.New("layerpack: file changed while it was read")
	ErrTooLarge    = errors.New("layerpack: layer is over a limit")
	ErrEmpty       = errors.New("layerpack: roots hold no file")
)

Functions

This section is empty.

Types

type Limits

type Limits struct{ Files, Bytes int64 }

type Options

type Options struct {
	// Mount is where the workspace mounts. An absolute symlink that points below it, outside every root, would
	// break in another workspace.
	Mount  string
	Roots  []string
	Limits Limits
	// Workers read files at once. Zero is 8.
	Workers int
	// BatchObjects is the most objects of one put. Zero is 4096.
	BatchObjects int
	// Uploads is the number of puts of blobs that run at once. Zero is 4.
	Uploads int
	// Progress, when set, receives the counts of the pack.
	Progress *Progress
}

type Progress added in v0.41.0

type Progress struct {
	Files, Bytes      atomic.Int64
	Uploaded, Skipped atomic.Int64
	// Objects and Batches count the objects that the pack put and the puts that held them, a blob put alone included.
	Objects, Batches atomic.Int64
}

Progress counts what a pack has done so far. A caller reads it while the pack runs.

func (*Progress) Attrs added in v0.41.0

func (g *Progress) Attrs() []attribute.KeyValue

Attrs returns the counts as span attributes.

type Result

type Result struct {
	Tree         gitpack.SHA
	Files, Bytes int64
}

func Pack

func Pack(ctx context.Context, fsys fs.FS, st Store, o Options) (Result, error)

Pack stores the blobs, then the trees, of the files below Options.Roots in fsys, and returns the root tree. It keeps each root at its own path in the tree. A root that does not exist is skipped, and a directory with no file is left out.

type Store

type Store interface {
	Has(ctx context.Context, shas []gitpack.SHA) ([]bool, error)
	PutObjects(ctx context.Context, objs []gitpack.Object) error
	PutBlob(ctx context.Context, sha gitpack.SHA, size int64, r io.Reader) error
}

Store is the part of the object store that a pack needs. A PutObjects call that fails may have stored a prefix of its objects, because an adapter splits a batch into requests, and each request stores all its objects or none. A pack puts every blob before any tree, and every tree after the trees below it, in that order within a call, so any prefix that the store holds is closed: a tree that the store holds never names a missing object. Pack calls PutObjects and PutBlob from several goroutines at once while it puts blobs, and from one goroutine at a time while it puts trees. PutBlob can return before it stops reading r, so the caller never uses r again after a failure.

Jump to

Keyboard shortcuts

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