catfile

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBatchfileTTL is the default ttl for batch files to live in the cache
	DefaultBatchfileTTL = 10 * time.Second

	// CacheMaxItems is the default configuration for maximum entries in the batch cache
	CacheMaxItems = 100
)
View Source
const (
	// CacheFeatureFlagKey is the feature flag key for catfile batch caching. This should match
	// what is in gitlab-ce
	CacheFeatureFlagKey = "catfile-cache"
)

Variables

This section is empty.

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

func IsNotFound(err error) bool

IsNotFound tests whether err has type NotFoundError.

Types

type Batch added in v0.92.0

type Batch struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func New(ctx context.Context, repo *gitalypb.Repository) (*Batch, error)

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

func (c *Batch) Blob(revspec string) (io.Reader, error)

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

func (c *Batch) Commit(revspec string) (io.Reader, error)

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) 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

func (c *Batch) Tag(revspec string) (io.Reader, error)

Tag returns a raw tag object. Caller must consume the Reader before making another call on C.

func (*Batch) Tree added in v0.92.0

func (c *Batch) Tree(revspec string) (io.Reader, error)

Tree returns a raw tree object. It is an error if revspec does not point to a tree. To prevent this firstuse Info to resolve the revspec and check the object type. Caller must consume the Reader before making another call on C.

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

type ObjectInfo struct {
	Oid  string
	Type string
	Size int64
}

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"

Jump to

Keyboard shortcuts

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