Documentation
¶
Overview ¶
Package store keeps the git objects of a repository in packs and the operation objects of a workspace, in one object store. HTTP, grants and the SQL index are in other packages.
Index ¶
- Constants
- Variables
- func ValidWorkspaceID(id string) bool
- type Entry
- type OpKind
- type PackIndex
- type Reader
- type Repo
- type Service
- func (s *Service) Blobs(ctx context.Context, repo Repo, shas []gitpack.SHA) ([][]byte, error)
- func (s *Service) Commit(ctx context.Context, repo Repo, sha gitpack.SHA) (gitpack.SHA, time.Time, error)
- func (s *Service) Get(ctx context.Context, repo Repo, sha gitpack.SHA) (gitpack.Type, []byte, error)
- func (s *Service) GetOp(ctx context.Context, ws string, kind OpKind, id string) ([]byte, error)
- func (s *Service) Has(ctx context.Context, repo Repo, shas []gitpack.SHA) ([]bool, error)
- func (s *Service) ImportPack(ctx context.Context, repo Repo, id string, idx, pack []byte) error
- func (s *Service) PutObjects(ctx context.Context, repo Repo, objs []gitpack.Object) ([]gitpack.SHA, error)
- func (s *Service) PutOp(ctx context.Context, ws string, kind OpKind, id string, data []byte) error
- func (s *Service) Reader(ctx context.Context, repo Repo) (*Reader, error)
- func (s *Service) ReceivePack(ctx context.Context, repo Repo, pack []byte) error
- func (s *Service) Reserve(ctx context.Context, bytes int64) (release func(), err error)
- func (s *Service) TreeBulk(ctx context.Context, repo Repo, sha gitpack.SHA, maxEntries int, ...) ([]Tree, error)
- func (s *Service) Warm(ctx context.Context, repos []Repo, parallel int) error
- type Stats
- type Tree
Constants ¶
const ( MaxOpBytes = 8 << 20 MaxPackBytes = 64 << 20 MaxIdxBytes = 8 << 20 // MaxBlobBatchBytes bounds the blobs that one batch read returns. MaxBlobBatchBytes = 16 << 20 // MaxBatch bounds the objects of one put. MaxBatch = 100000 // MemoryBudget is the bytes that requests may hold while they work, apart from the bodies that are still being read. MemoryBudget = 512 << 20 )
Variables ¶
Functions ¶
func ValidWorkspaceID ¶
ValidWorkspaceID reports whether id can name a workspace.
Types ¶
type PackIndex ¶
type PackIndex interface {
AddPack(ctx context.Context, repo, packID string, bytes int64) error
Packs(ctx context.Context, repo string) ([]meta.Pack, error)
}
PackIndex lists the packs of a repo, oldest first.
type Reader ¶ added in v0.6.0
type Reader struct {
// contains filtered or unexported fields
}
Reader reads the objects of one repo against the pack list of the moment that Reader was called, so a request that reads many objects lists the packs once.
type Repo ¶
type Repo struct{ Prefix, Path string }
Repo names a repository as <prefix>:<path>.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service stores the objects of every repo and workspace in one object store.
func (*Service) Commit ¶
func (s *Service) Commit(ctx context.Context, repo Repo, sha gitpack.SHA) (gitpack.SHA, time.Time, error)
Commit returns the tree of a commit and its committer time.
func (*Service) Has ¶
Has reports for each sha whether a pack of the repo holds it. It reads the pack indexes only.
func (*Service) ImportPack ¶
ImportPack stores a pack and its v2 index under the SHA-256 of the pack.
func (*Service) PutObjects ¶
func (s *Service) PutObjects(ctx context.Context, repo Repo, objs []gitpack.Object) ([]gitpack.SHA, error)
PutObjects stores objects as one pack and returns their names in order.
func (*Service) ReceivePack ¶ added in v0.6.0
ReceivePack stores the objects of a pushed pack as one pack of the repo. The pack may be thin: the service resolves the base of a ref delta from the repo, so the stored pack holds whole objects.
func (*Service) Reserve ¶ added in v0.5.0
Reserve takes bytes of MemoryBudget, at most the whole budget, and waits while the budget is spent. The caller releases it.
func (*Service) TreeBulk ¶
func (s *Service) TreeBulk(ctx context.Context, repo Repo, sha gitpack.SHA, maxEntries int, grow func(treeBytes int64) error) ([]Tree, error)
TreeBulk returns a tree and its subtrees breadth first, until the entries returned reach maxEntries. Blob entries carry their size. Before it reads a tree, it calls grow with the tree bytes of the trees read so far and this one, taken from the pack index.
type Stats ¶
type Stats struct {
Objects, Bytes, Packs, RangeReads, RangeBytes, MaxDepth, SlotWaitNanos atomic.Int64
}
Stats counts what one request read from the store. A handler puts one in the context with WithStats and reads it when the request ends. A nil *Stats counts nothing.
func (*Stats) AddSlotWait ¶
AddSlotWait adds the time a request waited for a weighted slot.