layers

package
v0.41.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: 16 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

View Source
const (
	Running = "running"
	Done    = "done"
	Failed  = "failed"
	None    = "none"
)
View Source
const FilePath = ".motte/layers.json"

Variables

View Source
var (
	ErrInvalid = errors.New("layers: invalid declaration")
	ErrBusy    = errors.New("layers: too many packs at once")
	ErrClosed  = errors.New("layers: the workspace is closed")
)
View Source
var ErrFile = errors.New("layers: bad layer file")

ErrFile is a layer file that no layer can come from.

View Source
var ErrIndex = errors.New("layers: no such layer")

ErrIndex is a layer index that the commit does not declare.

Functions

func KeyOf

func KeyOf(read func(name string) ([]byte, error), d Declaration) (string, error)

KeyOf is Key over any reader of the input files, such as the tree of a commit.

Types

type Declaration

type Declaration struct {
	Platform string   `json:"platform"`
	Mount    string   `json:"mount"`
	Roots    []string `json:"roots"`
	Tools    []Tool   `json:"tools"`
	Files    []string `json:"files"`
	// Index is the place of the layer in the layer file.
	Index int `json:"-"`
}

Declaration is one layer of a workspace, with the platform, the mount path and the tool versions of its environment. Files are the paths of the install inputs, relative to the root of the tree. The service hashes them itself, so a caller cannot claim inputs that the files do not have.

func Resolve

func Resolve(read func(name string) ([]byte, error), env volume.LayerEnv) ([]Declaration, error)

type Service

type Service struct {

	// Tel carries the logger and the tracer of the node daemon. The zero value logs and traces nothing.
	Tel tel.Telemetry
	// contains filtered or unexported fields
}

Service packs layers of the merged view of one workspace, at most maxActive at a time, and keeps the state of at most maxRetained packs. A state that it dropped is read again from the stored row.

func New

func New(ctx context.Context, fsys fs.FS, st Store, limits layerpack.Limits, decls []Declaration) *Service

New returns the service of the merged view fsys. The packs end when ctx ends.

func (*Service) Close

func (s *Service) Close()

Close refuses new requests, and waits for every request and pack to end. The owner ends the context of New first. A pack that reads the merged view keeps its mount busy, so the owner closes before it unmounts.

func (*Service) Key

func (s *Service) Key(d Declaration) (string, error)

Key hashes the declared input files and returns the key of the layer.

func (*Service) Pack

func (s *Service) Pack(ctx context.Context, d Declaration) (string, error)

Pack starts the pack of the layer that d declares and returns its key. It starts nothing when a pack of the key runs or is done, or when the store has the row. A failed pack starts again. A failed lookup is an error, because it does not show that the row is absent.

func (*Service) PackDeclared

func (s *Service) PackDeclared(ctx context.Context, index *int) ([]string, error)

PackDeclared starts the pack of the layer at index in the file, or of every declared layer when index is nil, and returns the keys in the order of the file. A layer that Resolve left out has no key. A commit with no layers gives none.

func (*Service) State

func (s *Service) State(ctx context.Context, key string) State

State reports the pack of key. A key without a pack is Done when the store has its row.

func (*Service) Wait

func (s *Service) Wait(ctx context.Context, key string) State

Wait blocks until the pack of key ends, and returns its state. It returns at once for a key with no pack.

type State

type State struct {
	State        string
	Tree         string
	Files, Bytes int64
	Err          string
	// Hashed, Uploaded and Skipped count the work of the pack, which a running pack updates.
	HashedFiles, HashedBytes, UploadedBytes, SkippedBytes int64
}

type Store

type Store interface {
	layerpack.Store
	PutLayer(ctx context.Context, key, tree string, files, bytes int64) (layerrow.Row, error)
	Layer(ctx context.Context, key string) (layerrow.Row, error)
}

type Tool

type Tool struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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