cache

package
v0.0.0-...-afecb3f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Adapted from https://github.com/thought-machine/please Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Package cache abstracts storing and fetching previously run tasks

Adapted from https://github.com/thought-machine/please Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Package cache implements our cache abstraction.

Adapted from https://github.com/thought-machine/please Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Adapted from https://github.com/thought-machine/please Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCachesEnabled = errors.New("no caches are enabled")

ErrNoCachesEnabled is returned when both the filesystem and http cache are unavailable

Functions

func AddFlags

func AddFlags(opts *Opts, flags *pflag.FlagSet)

AddFlags adds cache-related flags to the given FlagSet

func DefaultLocation

func DefaultLocation(repoRoot titanpath.AbsoluteSystemPath) titanpath.AbsoluteSystemPath

DefaultLocation returns the default filesystem cache location, given a repo root

func WriteCacheMetaFile

func WriteCacheMetaFile(path titanpath.AbsoluteSystemPath, config *CacheMetadata) error

WriteCacheMetaFile writes cache metadata file at a path

Types

type ArtifactSignatureAuthentication

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

type Cache

type Cache interface {
	// Fetch returns true if there is a cache it. It is expected to move files
	// into their correct position as a side effect
	Fetch(anchor titanpath.AbsoluteSystemPath, hash string, files []string) (bool, []titanpath.AnchoredSystemPath, int, error)
	Exists(hash string) (ItemStatus, error)
	// Put caches files for a given hash
	Put(anchor titanpath.AbsoluteSystemPath, hash string, duration int, files []titanpath.AnchoredSystemPath) error
	Clean(anchor titanpath.AbsoluteSystemPath)
	CleanAll()
	Shutdown()
}

Cache is abstracted way to cache/fetch previously run tasks

func New

func New(opts Opts, repoRoot titanpath.AbsoluteSystemPath, client client, recorder analytics.Recorder, onCacheRemoved OnCacheRemoved) (Cache, error)

New creates a new cache

type CacheEvent

type CacheEvent struct {
	Source   string `mapstructure:"source"`
	Event    string `mapstructure:"event"`
	Hash     string `mapstructure:"hash"`
	Duration int    `mapstructure:"duration"`
}

type CacheMetadata

type CacheMetadata struct {
	Hash     string `json:"hash"`
	Duration int    `json:"duration"`
}

CacheMetadata stores duration and hash information for a cache entry so that aggregate Time Saved calculations can be made from artifacts from various caches

func ReadCacheMetaFile

func ReadCacheMetaFile(path titanpath.AbsoluteSystemPath) (*CacheMetadata, error)

ReadCacheMetaFile reads cache metadata file at a path

type ItemStatus

type ItemStatus struct {
	Local  bool `json:"local"`
	Remote bool `json:"remote"`
}

ItemStatus holds whether artifacts exists for a given hash on local and/or remote caching server

type OnCacheRemoved

type OnCacheRemoved = func(cache Cache, err error)

OnCacheRemoved defines a callback that the cache system calls if a particular cache needs to be removed. In practice, this happens when Remote Caching has been disabled the but CLI continues to try to use it.

type Opts

type Opts struct {
	OverrideDir     string
	SkipRemote      bool
	SkipFilesystem  bool
	Workers         int
	RemoteCacheOpts fs.RemoteCacheOptions
}

Opts holds configuration options for the cache TODO(gsoltis): further refactor this into fs cache opts and http cache opts

type StreamValidator

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

func (*StreamValidator) CurrentValue

func (sv *StreamValidator) CurrentValue() string

func (*StreamValidator) Validate

func (sv *StreamValidator) Validate(expectedTag string) bool

Jump to

Keyboard shortcuts

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