runcache

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TaskOutputModes

func TaskOutputModes() string

TaskOutputModes creates the description string for task outputs

Types

type LogReplayer

type LogReplayer = func(logger hclog.Logger, output *cli.PrefixedUi, logFile turbopath.AbsoluteSystemPath)

LogReplayer is a function that is responsible for replaying the contents of a given log file

type NoOpOutputWatcher

type NoOpOutputWatcher struct{}

NoOpOutputWatcher implements OutputWatcher, but always considers every glob to have changed

func (NoOpOutputWatcher) GetChangedOutputs

func (NoOpOutputWatcher) GetChangedOutputs(_ context.Context, _ string, repoRelativeOutputGlobs []string) ([]string, int, error)

GetChangedOutputs implements OutputWatcher.GetChangedOutputs. Since this is a no-op watcher, no tracking is done.

func (NoOpOutputWatcher) NotifyOutputsWritten

func (NoOpOutputWatcher) NotifyOutputsWritten(_ context.Context, _ string, _ hash.TaskOutputs, _ int) error

NotifyOutputsWritten implements OutputWatcher.NotifyOutputsWritten. Since this is a no-op watcher, consider all globs to have changed

type Opts

type Opts struct {
	SkipReads              bool
	SkipWrites             bool
	TaskOutputModeOverride *util.TaskOutputMode
	LogReplayer            LogReplayer
	OutputWatcher          OutputWatcher
}

Opts holds the configurable options for a RunCache instance

func (*Opts) SetTaskOutputMode

func (opts *Opts) SetTaskOutputMode(value string) error

SetTaskOutputMode parses the task output mode from string and then sets it in opts

type OutputWatcher

type OutputWatcher interface {
	// GetChangedOutputs returns which of the given globs have changed since the specified hash was last run
	GetChangedOutputs(ctx context.Context, hash string, repoRelativeOutputGlobs []string) ([]string, int, error)
	// NotifyOutputsWritten tells the watcher that the given globs have been cached with the specified hash
	NotifyOutputsWritten(ctx context.Context, hash string, repoRelativeOutputGlobs hash.TaskOutputs, timeSaved int) error
}

OutputWatcher instances are responsible for tracking changes to task outputs

type RunCache

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

RunCache represents the interface to the cache for a single `turbo run`

func New

func New(cache cache.Cache, repoRoot turbopath.AbsoluteSystemPath, opts Opts, colorCache *colorcache.ColorCache) *RunCache

New returns a new instance of RunCache, wrapping the given cache

func (*RunCache) TaskCache

func (rc *RunCache) TaskCache(pt *nodes.PackageTask, packageTaskHash string) TaskCache

TaskCache returns a TaskCache instance, providing an interface to the underlying cache specific to this run and the given PackageTask

type TaskCache

type TaskCache struct {
	ExpandedOutputs []turbopath.AnchoredSystemPath

	LogFileName turbopath.AbsoluteSystemPath
	// contains filtered or unexported fields
}

TaskCache represents a single task's (package-task?) interface to the RunCache and controls access to the task's outputs

func (TaskCache) OnError

func (tc TaskCache) OnError(terminal *cli.PrefixedUi, logger hclog.Logger)

OnError replays the logfile if --output-mode=errors-only. This is called if the task exited with an non-zero error code.

func (TaskCache) OutputWriter

func (tc TaskCache) OutputWriter(prefix string, ioWriter io.Writer) (io.WriteCloser, error)

OutputWriter creates a sink suitable for handling the output of the command associated with this task.

func (TaskCache) ReplayLogFile

func (tc TaskCache) ReplayLogFile(prefixedUI *cli.PrefixedUi, progressLogger hclog.Logger)

ReplayLogFile writes out the stored logfile to the terminal

func (*TaskCache) RestoreOutputs

func (tc *TaskCache) RestoreOutputs(ctx context.Context, prefixedUI *cli.PrefixedUi, progressLogger hclog.Logger) (cache.ItemStatus, error)

RestoreOutputs attempts to restore output for the corresponding task from the cache. Returns the cacheStatus, the timeSaved, and error values, so the consumer can understand what happened in here.

func (*TaskCache) SaveOutputs

func (tc *TaskCache) SaveOutputs(ctx context.Context, logger hclog.Logger, terminal cli.Ui, duration int) error

SaveOutputs is responsible for saving the outputs of task to the cache, after the task has completed

Jump to

Keyboard shortcuts

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