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 ¶
- Variables
- type Cache
- type DiskCache
- func (c *DiskCache) Collect(metrics chan<- prometheus.Metric)
- func (c *DiskCache) Describe(descs chan<- *prometheus.Desc)
- func (c *DiskCache) GetStream(ctx context.Context, repo *gitalypb.Repository, req proto.Message) (_ io.ReadCloser, err error)
- func (c *DiskCache) KeyPath(ctx context.Context, repo *gitalypb.Repository, req proto.Message) (string, error)
- func (c *DiskCache) PutStream(ctx context.Context, repo *gitalypb.Repository, req proto.Message, ...) error
- func (c *DiskCache) StartLease(repo *gitalypb.Repository) (LeaseEnder, error)
- func (c *DiskCache) StartWalkers() error
- func (c *DiskCache) StopWalkers()
- type Invalidator
- type LeaseEnder
- type Option
- type Streamer
Constants ¶
This section is empty.
Variables ¶
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") )
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 interface { Streamer Invalidator }
Cache is a stream-oriented cache which stores RPC responses keyed by protobuf requests.
type DiskCache ¶
type DiskCache struct {
// contains filtered or unexported fields
}
DiskCache stores and retrieves byte streams for repository related RPCs
func (*DiskCache) Collect ¶
func (c *DiskCache) Collect(metrics chan<- prometheus.Metric)
Collect is used to collect Prometheus metrics.
func (*DiskCache) Describe ¶
func (c *DiskCache) Describe(descs chan<- *prometheus.Desc)
Describe is used to describe Prometheus metrics.
func (*DiskCache) GetStream ¶
func (c *DiskCache) 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 (*DiskCache) KeyPath ¶
func (c *DiskCache) KeyPath(ctx context.Context, repo *gitalypb.Repository, req proto.Message) (string, error)
KeyPath returns the cache path for the given request.
func (*DiskCache) PutStream ¶
func (c *DiskCache) 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 (*DiskCache) StartLease ¶
func (c *DiskCache) 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 (*DiskCache) StartWalkers ¶
StartWalkers starts the cache walker Goroutines. Initially, this function will try to clean up any preexisting cache directories.
func (*DiskCache) StopWalkers ¶
func (c *DiskCache) StopWalkers()
StopWalkers stops all walkers started by StartWalkers.
type Invalidator ¶
type Invalidator interface {
StartLease(*gitalypb.Repository) (LeaseEnder, error)
}
Invalidator is able to invalidate parts of the cache pertinent to a specific repository. Before a repo mutating operation, StartLease should be called. Once the operation is complete, the returned LeaseEnder should be invoked to end the lease.
type LeaseEnder ¶
LeaseEnder allows the caller to indicate when a lease is no longer needed