cache

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Commit(
		workDir string,
		art *artifact.Artifact,
		s strategy.CheckoutStrategy,
		l *agglog.AggLogger,
	) error
	Checkout(
		workDir string,
		art artifact.Artifact,
		s strategy.CheckoutStrategy,
		p *pb.ProgressBar,
	) error
	Status(workDir string, art artifact.Artifact, shortCircuit bool) (artifact.Status, error)
	Fetch(remoteSrc string, arts map[string]*artifact.Artifact) error
	Push(remoteDst string, arts map[string]*artifact.Artifact) error
}

A Cache provides a means to store Artifacts.

type InvalidChecksumError

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

InvalidChecksumError is an error case where a valid checksum was expected but not found.

func (InvalidChecksumError) Error

func (err InvalidChecksumError) Error() string

type LocalCache

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

A LocalCache is a Cache that uses a directory on a local filesystem.

func NewLocalCache

func NewLocalCache(dir string) (ch LocalCache, err error)

NewLocalCache initializes a LocalCache with a valid cache directory.

func (LocalCache) Checkout

func (cache LocalCache) Checkout(
	workspaceDir string,
	art artifact.Artifact,
	strat strategy.CheckoutStrategy,
	progress *pb.ProgressBar,
) (err error)

Checkout finds the artifact in the cache and adds a copy of/link to said artifact in the working directory.

func (LocalCache) Commit

func (ch LocalCache) Commit(
	workspaceDir string,
	art *artifact.Artifact,
	strat strategy.CheckoutStrategy,
	logger *agglog.AggLogger,
) (err error)

Commit calculates the checksum of the artifact, moves it to the cache, then performs a checkout.

func (LocalCache) Fetch

func (ch LocalCache) Fetch(
	remoteSrc string,
	artifacts map[string]*artifact.Artifact,
) error

Fetch downloads an Artifact from a remote location to the local cache.

This uses a map of Artifacts instead of a slice to ease both testing and calling code. Primarily, a Stage's outputs will be passed to this function, so it's convenient to pass stage.Outputs directly. This also eases testing, because transcribing the map into a slice would introduce non-determinism.

func (LocalCache) PathForChecksum

func (ch LocalCache) PathForChecksum(checksum string) (string, error)

PathForChecksum returns the expected location of an object with the given checksum in the cache. If the checksum has an invalid (e.g. empty) checksum value, this function returns an error.

func (LocalCache) Push

func (ch LocalCache) Push(remoteDst string, arts map[string]*artifact.Artifact) error

Push uploads an Artifact from the local cache to a remote cache.

This uses a map of Artifacts instead of a slice to ease both testing and calling code. Primarily, a Stage's outputs will be passed to this function, so it's convenient to pass stage.Outputs directly. This also eases testing, because transcribing the map into a slice would introduce non-determinism.

func (LocalCache) Status

func (ch LocalCache) Status(workspaceDir string, art artifact.Artifact, shortCircuit bool) (
	status artifact.Status,
	err error,
)

Status reports the status of an Artifact in the Cache. If shortCircuit is true, Status will exit as soon as the overall state of the Artifact is known -- saving time, but potentially leaving artifact.Status.ChildrenStatus incomplete. If shortCircuit is false, Status will fully populate artifact.Status.ChildrenStatus.

type MissingFromCacheError

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

MissingFromCacheError is an error case where a cache file was expected but not found.

func (MissingFromCacheError) Error

func (err MissingFromCacheError) Error() string

Jump to

Keyboard shortcuts

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