Documentation ¶
Index ¶
- Constants
- Variables
- func ExpireAll()
- func IsNotFound(err error) bool
- type Batch
- func (c *Batch) Blob(revspec string) (io.Reader, error)
- func (c *Batch) Close()
- func (c *Batch) Commit(revspec string) (io.Reader, error)
- func (c *Batch) HasUnreadData() bool
- func (c *Batch) Info(revspec string) (*ObjectInfo, error)
- func (c *Batch) Tag(revspec string) (io.Reader, error)
- func (c *Batch) Tree(revspec string) (io.Reader, error)
- type BatchCache
- type CacheItem
- type CacheKey
- type NotFoundError
- type ObjectInfo
Constants ¶
const ( // CacheFeatureFlagKey is the feature flag key for catfile batch caching. This should match // what is in gitlab-ce CacheFeatureFlagKey = "catfile-cache" // CacheMaxItems is the default configuration for maximum entries in the batch cache CacheMaxItems = 100 )
Variables ¶
var DefaultBatchfileTTL = 10 * time.Second
DefaultBatchfileTTL is the default ttl for batch files to live in the cache
Functions ¶
func ExpireAll ¶ added in v1.38.0
func ExpireAll()
ExpireAll is used to expire all of the batches in the cache
func IsNotFound ¶ added in v0.92.0
IsNotFound tests whether err has type NotFoundError.
Types ¶
type Batch ¶ added in v0.92.0
Batch abstracts 'git cat-file --batch' and 'git cat-file --batch-check'. It lets you retrieve object metadata and raw objects from a Git repo.
A Batch instance can only serve single request at a time. If you want to use it across multiple goroutines you need to add your own locking.
func New ¶ added in v0.92.0
New returns a new Batch instance. It is important that ctx gets canceled somewhere, because if it doesn't the cat-file processes spawned by New() never terminate.
func (*Batch) Blob ¶ added in v0.92.0
Blob returns a reader for the requested blob. The entire blob must be read before any new objects can be requested from this Batch instance.
It is an error if revspec does not point to a blob. To prevent this first use Info to resolve the revspec and check the object type.
func (*Batch) Close ¶ added in v1.38.0
func (c *Batch) Close()
Close closes the writers for batchCheck and batch. This is only used for cached Batches
func (*Batch) Commit ¶ added in v0.92.0
Commit returns a raw commit object. It is an error if revspec does not point to a commit. To prevent this first use Info to resolve the revspec and check the object type. Caller must consume the Reader before making another call on C.
func (*Batch) HasUnreadData ¶ added in v1.38.0
HasUnreadData returns a boolean specifying whether or not the Batch has more data still to be read
func (*Batch) Info ¶ added in v0.92.0
func (c *Batch) Info(revspec string) (*ObjectInfo, error)
Info returns an ObjectInfo if spec exists. If spec does not exist the error is of type NotFoundError.
func (*Batch) Tag ¶ added in v1.21.0
Tag returns a raw tag object. Caller must consume the Reader before making another call on C.
type BatchCache ¶ added in v1.38.0
BatchCache is a cache containing batch objects based on session id and repository path
func NewCache ¶ added in v1.38.0
func NewCache(maxEntries int) *BatchCache
NewCache creates a new BatchCache
func (*BatchCache) Add ¶ added in v1.38.0
func (bc *BatchCache) Add(key CacheKey, b *Batch, ttl time.Duration)
Add Adds a batch based on a CacheKey. If there is already a batch for the given key, it will remove and close the existing one, and Add the new one.
func (*BatchCache) Del ¶ added in v1.38.0
func (bc *BatchCache) Del(key CacheKey)
Del Deletes a batch based on a CacheKey
func (*BatchCache) Get ¶ added in v1.38.0
func (bc *BatchCache) Get(key CacheKey) *Batch
Get retrieves a batch based on a CacheKey. We remove it from the lru so that other processes can't Get it. however, since OnEvicted is called every time something is evicted from the cache, we need to signal to the OnEvicted function that we don't want this batch to be closed. Therefore, we will update the cache entry with preserveBatchOnEvict set to true.
type CacheItem ¶ added in v1.38.0
type CacheItem struct {
// contains filtered or unexported fields
}
CacheItem is a wrapper around Batch that provides a channel through which the ttl goroutine can be stopped
type CacheKey ¶ added in v1.38.0
type CacheKey struct {
// contains filtered or unexported fields
}
CacheKey is a key for the catfile cache
func NewCacheKey ¶ added in v1.38.0
func NewCacheKey(sessionID string, repo repository.GitRepo) CacheKey
NewCacheKey return a cache key based on a session id and a git repository
type NotFoundError ¶ added in v0.92.0
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError is returned when requesting an object that does not exist.
type ObjectInfo ¶
ObjectInfo represents a header returned by `git cat-file --batch`
func (*ObjectInfo) IsBlob ¶ added in v0.116.0
func (o *ObjectInfo) IsBlob() bool
IsBlob returns true if object type is "blob"