cache

package
v1.87.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 25 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 Keyer

type Keyer interface {
	// KeyPath will return a key filepath for the provided request. If an error
	// is returned, the cache should not be used.
	KeyPath(context.Context, *gitalypb.Repository, proto.Message) (string, error)
}

Keyer abstracts how to obtain a unique file path key for a request at a specific generation of the cache. The key path will magically update as new critical sections are declared. An error will be returned if the repo's cache has any open critical sections.

type LeaseEnder

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

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

type LeaseKeyer

type LeaseKeyer struct{}

LeaseKeyer will try to return a key path for the current generation of the repo's cache. It uses a strategy that avoids file locks in favor of atomically created/renamed files. Read more about LeaseKeyer's design: https://gitlab.com/gitlab-org/gitaly/issues/1745

func (LeaseKeyer) KeyPath

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

KeyPath will attempt to return the unique keypath for a request in the specified repo for the current generation. The context must contain the gRPC method in its values.

func (LeaseKeyer) StartLease

func (LeaseKeyer) 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.

type StreamDB

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

StreamDB stores and retrieves byte streams for repository related RPCs

func NewStreamDB

func NewStreamDB(ck Keyer) *StreamDB

NewStreamDB will open the stream database at the specified file path.

func (*StreamDB) GetStream

func (sdb *StreamDB) 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 (*StreamDB) PutStream

func (sdb *StreamDB) 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.

Jump to

Keyboard shortcuts

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