Documentation
¶
Index ¶
- Constants
- Variables
- func BaseKeyOf(d Declaration) (string, error)
- func KeyOf(read func(name string) ([]byte, error), d Declaration) (string, error)
- type Declaration
- type Mount
- type MountInfo
- type Service
- func (s *Service) Close()
- func (s *Service) Key(d Declaration) (string, error)
- func (s *Service) MountOf(key string) Mount
- func (s *Service) Mounts() []MountInfo
- func (s *Service) Pack(ctx context.Context, d Declaration) (string, error)
- func (s *Service) PackDeclared(ctx context.Context, index *int) ([]string, error)
- func (s *Service) SetMounts(mounted map[string]Mount, declared []MountInfo)
- func (s *Service) State(ctx context.Context, key string) State
- func (s *Service) Wait(ctx context.Context, key string) State
- type State
- type Store
- type Tool
Constants ¶
const ( Running = "running" Done = "done" Failed = "failed" None = "none" )
const FilePath = ".motte/layers.json"
Variables ¶
var ( ErrInvalid = errors.New("layers: invalid declaration") ErrBusy = errors.New("layers: too many packs at once") ErrClosed = errors.New("layers: the workspace is closed") )
var ErrFile = errors.New("layers: bad layer file")
ErrFile is a layer file that no layer can come from.
var ErrIndex = errors.New("layers: no such layer")
ErrIndex is a layer index that the commit does not declare.
Functions ¶
func BaseKeyOf ¶ added in v0.44.0
func BaseKeyOf(d Declaration) (string, error)
BaseKeyOf returns the base key of the layer that d declares: its key without the input files.
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.
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 ¶
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 ¶
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) SetMounts ¶ added in v0.44.0
SetMounts must run before the first request. mounted holds every key that the daemon mounted, and State reports it, also for a key that the commit no longer declares (a volume with edits remounts its record). declared has one entry for each declaration with a key, duplicates included.
type State ¶
type State struct {
State string
Tree string
Files, Bytes int64
Err string
// Hit is true when the daemon mounted the layer of this key at mount time. Base is the key of the layer that it
// mounted as a starting point instead: the files of a base mount are no proof of the inputs, and the caller runs its
// install. A key with a base is never a hit.
Hit bool
Base string
// Hashed, Uploaded and Skipped count the work of the pack, which a running pack updates.
HashedFiles, HashedBytes, UploadedBytes, SkippedBytes int64
}