cache

package
v14.0.0-rc43 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package cache supplies background workers for periodically cleaning the cache folder on all storages listed in the config file. Upon configuration validation, one worker will be started for each storage. The worker will walk the cache directory tree and remove any files older than one hour. The worker will walk the cache directory every ten minutes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingLeaseFile indicates a lease file does not exist on the
	// filesystem that the lease ender expected to be there
	ErrMissingLeaseFile = errors.New("lease file unexpectedly missing")
	// ErrInvalidUUID indicates an internal error with generating a UUID
	ErrInvalidUUID = errors.New("unable to generate valid UUID")
	// ErrCtxMethodMissing indicates the provided context does not contain the
	// expected information about the current gRPC method
	ErrCtxMethodMissing = errors.New("context does not contain gRPC method name")
	// ErrPendingExists indicates that there is a critical zone for the current
	// repository in the pending transition
	ErrPendingExists = errors.New("one or more cache generations are pending transition for the current repository")
)
View Source
var ErrReqNotFound = errors.New("request digest not found within repo namespace")

ErrReqNotFound indicates the request does not exist within the repo digest

Functions

This section is empty.

Types

type Cache

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

Cache stores and retrieves byte streams for repository related RPCs

func New

func New(cfg config.Cfg, locator storage.Locator, opts ...Option) *Cache

New will create a new Cache with the given Keyer.

func (*Cache) Collect

func (c *Cache) Collect(metrics chan<- prometheus.Metric)

Collect is used to collect Prometheus metrics.

func (*Cache) Describe

func (c *Cache) Describe(descs chan<- *prometheus.Desc)

Describe is used to describe Prometheus metrics.

func (*Cache) GetStream

func (c *Cache) GetStream(ctx context.Context, repo *gitalypb.Repository, req proto.Message) (_ io.ReadCloser, err error)

GetStream will fetch the cached stream for a request. It is the responsibility of the caller to close the stream when done.

func (*Cache) KeyPath

func (c *Cache) KeyPath(ctx context.Context, repo *gitalypb.Repository, req proto.Message) (string, error)

KeyPath returns the cache path for the given request.

func (*Cache) PutStream

func (c *Cache) PutStream(ctx context.Context, repo *gitalypb.Repository, req proto.Message, src io.Reader) error

PutStream will store a stream in a repo-namespace keyed by the digest of the request protobuf message.

func (*Cache) StartLease

func (c *Cache) StartLease(repo *gitalypb.Repository) (LeaseEnder, error)

StartLease will mark the repository as being in an indeterministic state. This is typically used when modifying the repo, since the cache is not stable until after the modification is complete. A lease object will be returned that allows the caller to signal the end of the lease.

func (*Cache) StartWalkers

func (c *Cache) StartWalkers() error

StartWalkers starts the cache walker Goroutines. Initially, this function will try to clean up any preexisting cache directories.

type LeaseEnder

type LeaseEnder interface {
	EndLease(context.Context) error
}

LeaseEnder allows the caller to indicate when a lease is no longer needed

type Option

type Option func(*cacheConfig)

Option is an option for the cache.

Jump to

Keyboard shortcuts

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