Documentation
¶
Index ¶
- Constants
- func CleanPath(x string) string
- func GetBlobBytes(ctx context.Context, s cadata.Getter, x Ref, maxSize int) ([]byte, error)
- func IsErrNoEnt(err error) bool
- func IsValidName(x string) bool
- func Replace(ents []TreeEntry, ent TreeEntry)
- func SizeOf(x Ref) uint64
- func SortTreeEntries(ents []TreeEntry)
- func Sync(ctx context.Context, dst cadata.PostExister, src cadata.Getter, x Ref) error
- func ValidateTreeEntries(ents []TreeEntry) error
- func WalkRefs(ctx context.Context, s cadata.Getter, ref Ref, fn RefWalker) error
- func WalkTree(ctx context.Context, store cadata.Getter, ref Ref, f WalkTreeFunc) error
- type AddExister
- type Agent
- func (ag *Agent) Compare(ctx context.Context, dst cadata.PostExister, src cadata.Getter, ...) (*Diff, error)
- func (ag *Agent) Concat(ctx context.Context, store cadata.Store, layers ...Ref) (*Ref, error)
- func (ag *Agent) FilterPaths(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Agent) GC(ctx context.Context, store GetListDeleter, keep []Ref, opts ...GCOption) (*GCResult, error)
- func (ag *Agent) GetAtPath(ctx context.Context, store cadata.Getter, ref Ref, subpath string) (*Ref, error)
- func (ag *Agent) GetBlob(ctx context.Context, s cadata.Getter, x Ref) (*Reader, error)
- func (ag *Agent) GetBlobBytes(ctx context.Context, s cadata.Getter, x Ref, maxSize int) ([]byte, error)
- func (ag *Agent) GetTreeSlice(ctx context.Context, store cadata.Getter, ref Ref, maxEnts int) ([]TreeEntry, error)
- func (ag *Agent) GetTyped(ctx context.Context, s cadata.Getter, ty Type, x Ref) (*Reader, error)
- func (ag *Agent) Lookup(ctx context.Context, store cadata.Getter, ent TreeEntry, subpath string) (*TreeEntry, error)
- func (ag *Agent) MapBlobs(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Agent) MapEntries(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Agent) MapEntryAt(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Agent) MapLeaves(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Agent) Merge(ctx context.Context, dst cadata.PostExister, src cadata.Getter, layers ...Ref) (*Ref, error)
- func (ag *Agent) NewBlobReader(ctx context.Context, s cadata.Getter, x Ref) (*Reader, error)
- func (ag *Agent) NewBlobWriter(s cadata.Poster) *TypedWriter
- func (ag *Agent) NewTreeReader(s cadata.Getter, x Ref) (*TreeReader, error)
- func (ag *Agent) NewTreeWriter(s cadata.PostExister) *TreeWriter
- func (ag *Agent) NewTypedWriter(s cadata.Poster, ty Type) *TypedWriter
- func (ag *Agent) Populate(ctx context.Context, store GetListDeleter, x Ref, dst AddExister) error
- func (ag *Agent) PostBlob(ctx context.Context, s cadata.Poster, r io.Reader) (*Ref, error)
- func (ag *Agent) PostTree(ctx context.Context, s cadata.PostExister, ents iter.Seq[TreeEntry]) (*Ref, error)
- func (ag *Agent) PostTreeMap(ctx context.Context, s cadata.PostExister, m map[string]Ref) (*Ref, error)
- func (ag *Agent) PostTreeSlice(ctx context.Context, dst cadata.PostExister, ents []TreeEntry) (*Ref, error)
- func (ag *Agent) PostTyped(ctx context.Context, s cadata.Poster, ty Type, r io.Reader) (*Ref, error)
- func (ag *Agent) ReadTreeFrom(r io.Reader) *TreeReader
- func (ag *Agent) ShardLeaves(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) ([]Ref, error)
- func (ag *Agent) Sync(ctx context.Context, dst cadata.PostExister, src cadata.Getter, x Ref) error
- func (ag *Agent) Traverse(ctx context.Context, s cadata.Getter, sem *semaphore.Weighted, x Ref, ...) error
- func (ag *Agent) WalkRefs(ctx context.Context, s cadata.Getter, ref Ref, fn RefWalker) error
- func (ag *Agent) WalkTree(ctx context.Context, store cadata.Getter, ref Ref, f WalkTreeFunc) error
- type BlobMapper
- type Diff
- type ErrNoEnt
- type ErrRefType
- type GCOption
- type GCResult
- type GetListDeleter
- type Option
- type PostLister
- type Reader
- type Ref
- func FilterPaths(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func GetAtPath(ctx context.Context, store cadata.Getter, ref Ref, subpath string) (*Ref, error)
- func MapBlobs(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func MapEntryAt(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func MapLeaves(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func Merge(ctx context.Context, dst cadata.PostExister, src cadata.Getter, layers ...Ref) (*Ref, error)
- func MustPostBlob(s cadata.Poster, x []byte) Ref
- func MustPostTreeMap(s cadata.PostExister, m map[string]Ref) Ref
- func MustPostTreeSlice(s cadata.PostExister, ents []TreeEntry) Ref
- func PostBlob(ctx context.Context, s cadata.Poster, r io.Reader) (*Ref, error)
- func PostTree(ctx context.Context, s cadata.PostExister, ents iter.Seq[TreeEntry]) (*Ref, error)
- func PostTreeMap(ctx context.Context, s cadata.PostExister, m map[string]Ref) (*Ref, error)
- func PostTreeSlice(ctx context.Context, s cadata.PostExister, ents []TreeEntry) (*Ref, error)
- func PostTyped(ctx context.Context, s cadata.Poster, ty Type, r io.Reader) (*Ref, error)
- func ShardLeaves(ctx context.Context, dst cadata.PostExister, s cadata.Getter, root Ref, n int) ([]Ref, error)
- type RefMapper
- type RefWalker
- type Traverser
- type TreeEntry
- type TreeEntryMapper
- type TreeReader
- type TreeWriter
- type Type
- type TypedWriter
- type WalkTreeFunc
Constants ¶
const ( TypeBlob = Type("blob") TypeTree = Type("tree") )
const DefaultBlockSize = 1 << 21
Variables ¶
This section is empty.
Functions ¶
func GetBlobBytes ¶
GetBlobBytes reads the entire contents of the blob at x into memory and returns the slice of bytes.
func IsErrNoEnt ¶
func IsValidName ¶
IsValidName returns true if x can be used as a TreeEntry name
func SortTreeEntries ¶
func SortTreeEntries(ents []TreeEntry)
func Sync ¶
Sync ensures that all data referenced by x exists in dst, copying from src if necessary. Sync assumes there are no dangling references, and skips copying data when its existence is implied.
func ValidateTreeEntries ¶
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) Compare ¶
func (ag *Agent) Compare(ctx context.Context, dst cadata.PostExister, src cadata.Getter, left, right Ref) (*Diff, error)
Compare compares left and right and returns a diff. Left and right must both point only to data in s.
func (*Agent) FilterPaths ¶
func (ag *Agent) FilterPaths(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, f func(string) bool) (*Ref, error)
FilterPaths returns a version of root with paths filtered using f as a predicate. If f returns true for a path it will be included in the output, otherwise it will not.
func (*Agent) GC ¶
func (ag *Agent) GC(ctx context.Context, store GetListDeleter, keep []Ref, opts ...GCOption) (*GCResult, error)
GC will remove objects from store which are not referenced by any of the refs in keep. If GC does not successfully complete, referential integrity may be violated, and GC will need to be run to completion before it is safe to call Sync on the store again.
func (*Agent) GetAtPath ¶
func (ag *Agent) GetAtPath(ctx context.Context, store cadata.Getter, ref Ref, subpath string) (*Ref, error)
GetAtPath returns a ref to the object under ref at subpath. ErrNoEnt is returned if there is no entry at that path.
func (*Agent) GetBlobBytes ¶
func (ag *Agent) GetBlobBytes(ctx context.Context, s cadata.Getter, x Ref, maxSize int) ([]byte, error)
GetBlobBytes reads the entire contents of the blob at x into memory and returns the slice of bytes.
func (*Agent) GetTreeSlice ¶
func (ag *Agent) GetTreeSlice(ctx context.Context, store cadata.Getter, ref Ref, maxEnts int) ([]TreeEntry, error)
GetTree retreives the tree in store at Ref if it exists. If ref.Type != TypeTree ErrRefType is returned.
func (*Agent) GetTyped ¶
GetTyped retrieves the object in s at x. If x.Type != ty, ErrRefType is returned.
func (*Agent) MapEntries ¶
func (*Agent) MapEntryAt ¶
func (*Agent) Merge ¶
func (ag *Agent) Merge(ctx context.Context, dst cadata.PostExister, src cadata.Getter, layers ...Ref) (*Ref, error)
Merge merges the refs in layers with increasing prescedence. layer[i+1] is higher prescendence than layer[i]
Merging is associative, but not commutative Merge(tree, blob) -> blob Merge(blob, tree) -> tree Merge(tree1, tree2) -> set of entry names given by tree1 + tree2. value at entry x given by Merge(tree1[x], tree2[x]) Although not written as such for performance reasons: Merging(1, 2, 3, 4, 5) == Merge(Merge(Merge(Merge(1, 2), 3), 4), 5)
Merge will call Sync to protect referential integrity in dst.
func (*Agent) NewBlobReader ¶
func (*Agent) NewBlobWriter ¶
func (ag *Agent) NewBlobWriter(s cadata.Poster) *TypedWriter
func (*Agent) NewTreeReader ¶
func (*Agent) NewTreeWriter ¶
func (ag *Agent) NewTreeWriter(s cadata.PostExister) *TreeWriter
func (*Agent) NewTypedWriter ¶
func (ag *Agent) NewTypedWriter(s cadata.Poster, ty Type) *TypedWriter
NewTypedWriter returns a new writer for ty.
func (*Agent) Populate ¶
func (ag *Agent) Populate(ctx context.Context, store GetListDeleter, x Ref, dst AddExister) error
Populate adds everything reachable form x to dst
func (*Agent) PostTreeMap ¶
func (*Agent) PostTreeSlice ¶
func (*Agent) PostTyped ¶
func (ag *Agent) PostTyped(ctx context.Context, s cadata.Poster, ty Type, r io.Reader) (*Ref, error)
PostTyped posts data with an arbitrary type. This can be used to extend the types provided by glfs, without interfering with syncing.
func (*Agent) ReadTreeFrom ¶
func (ag *Agent) ReadTreeFrom(r io.Reader) *TreeReader
func (*Agent) ShardLeaves ¶
func (*Agent) Sync ¶
Sync ensures that all data referenced by x exists in dst, copying from src if necessary. Sync assumes there are no dangling references, and skips copying data when its existence is implied.
type Diff ¶
Diff contains the result of a Compare Left contains only elements in left Right contains only elements in right Both contains elements common to left and right
type ErrRefType ¶
type ErrRefType struct {
Have, Want Type
}
func (ErrRefType) Error ¶
func (e ErrRefType) Error() string
type GCResult ¶
type Ref ¶
Ref is a reference to a glfs Object, which could be: - Tree - Blob
func FilterPaths ¶
func FilterPaths(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, f func(string) bool) (*Ref, error)
FilterPaths returns a version of root with paths filtered using f as a predicate. If f returns true for a path it will be included in the output, otherwise it will not.
func GetAtPath ¶
GetAtPath returns a ref to the object under ref at subpath. ErrNoEnt is returned if there is no entry at that path.
func MapBlobs ¶
func MapBlobs(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, f BlobMapper) (*Ref, error)
MapBlobs calls MapBlobs on the default Agent
func MapEntryAt ¶
func MapEntryAt(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, p string, f TreeEntryMapper) (*Ref, error)
MapEntryAt calls MapEntryAt on the default Agent
func MapLeaves ¶
func MapLeaves(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, f RefMapper) (*Ref, error)
MapLeaves calls MapLeaves on the default Agent
func Merge ¶
func Merge(ctx context.Context, dst cadata.PostExister, src cadata.Getter, layers ...Ref) (*Ref, error)
Merge calls Merge on the default Agent
func MustPostTreeMap ¶
func MustPostTreeMap(s cadata.PostExister, m map[string]Ref) Ref
func MustPostTreeSlice ¶
func MustPostTreeSlice(s cadata.PostExister, ents []TreeEntry) Ref
func PostTreeMap ¶
func PostTreeSlice ¶
type Traverser ¶
type Traverser struct { // Enter is called before visiting a node, if false is returned the node is skipped. Enter func(ctx context.Context, id cadata.ID) (bool, error) // Exit is called before leaving a node. After all it's children have been visited. Exit func(ctx context.Context, ty Type, level int, ref bigblob.Ref) error }
type TreeEntry ¶
type TreeEntry struct { Name string `json:"name"` FileMode os.FileMode `json:"mode"` Ref Ref `json:"ref"` }
TreeEntry is a single entry in a tree, uniquely identified by Name
func GetTreeSlice ¶
func GetTreeSlice(ctx context.Context, store cadata.Getter, ref Ref, maxEnts int) ([]TreeEntry, error)
GetTreeSlice retreives the tree in store at Ref if it exists. If ref.Type != TypeTree ErrRefType is returned.
type TreeEntryMapper ¶
type TreeReader ¶
type TreeReader struct {
// contains filtered or unexported fields
}
type TreeWriter ¶
type TreeWriter struct {
// contains filtered or unexported fields
}
type TypedWriter ¶
type TypedWriter struct {
// contains filtered or unexported fields
}
func (*TypedWriter) SetWriteContext ¶
func (tw *TypedWriter) SetWriteContext(ctx context.Context)
type WalkTreeFunc ¶
WalkTreeFunc is the type of functions passed to WalkTree