Documentation
¶
Overview ¶
Package blob stores content-addressed objects: file contents and trees.
Objects are immutable. Put returns the hash of the object, and storing the same bytes twice is a no-op. Every read is verified against its hash, so a corrupted store fails loudly instead of returning wrong content.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCorrupt = errors.New("object corrupt")
ErrCorrupt is returned when stored bytes do not match their hash.
var ErrNotFound = errors.New("object not found")
ErrNotFound is returned when an object is not in the store.
Functions ¶
Types ¶
type Disk ¶
type Disk struct {
// contains filtered or unexported fields
}
Disk stores objects as files under a root directory, fanned out by the first two bytes of the hash: root/9f/1c/9f1c....
type Mem ¶
type Mem struct {
// contains filtered or unexported fields
}
Mem is an in-memory Store for tests and short-lived work.
type Store ¶
type Store interface {
// Put stores data under the hash of kind and data.
Put(ctx context.Context, kind hash.Kind, data []byte) (hash.Hash, error)
// Get returns the object and its kind.
Get(ctx context.Context, h hash.Hash) (hash.Kind, []byte, error)
// Has reports whether the object exists.
Has(ctx context.Context, h hash.Hash) (bool, error)
}
Store is a content-addressed object store.