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 BlobMapper
- type Diff
- type ErrNoEnt
- type ErrRefType
- type GCOption
- type GCResult
- type GetListDeleter
- type Machine
- func (ag *Machine) Compare(ctx context.Context, dst cadata.PostExister, src cadata.Getter, ...) (*Diff, error)
- func (ag *Machine) Concat(ctx context.Context, store cadata.Store, layers ...Ref) (*Ref, error)
- func (ag *Machine) FilterPaths(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Machine) GC(ctx context.Context, store GetListDeleter, keep []Ref, opts ...GCOption) (*GCResult, error)
- func (ag *Machine) GetAtPath(ctx context.Context, store cadata.Getter, ref Ref, subpath string) (*Ref, error)
- func (ag *Machine) GetBlob(ctx context.Context, s cadata.Getter, x Ref) (*Reader, error)
- func (ag *Machine) GetBlobBytes(ctx context.Context, s cadata.Getter, x Ref, maxSize int) ([]byte, error)
- func (ag *Machine) GetTreeSlice(ctx context.Context, store cadata.Getter, ref Ref, maxEnts int) ([]TreeEntry, error)
- func (ag *Machine) GetTyped(ctx context.Context, s cadata.Getter, ty Type, x Ref) (*Reader, error)
- func (ag *Machine) Lookup(ctx context.Context, store cadata.Getter, ent TreeEntry, subpath string) (*TreeEntry, error)
- func (ag *Machine) MapBlobs(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Machine) MapEntries(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Machine) MapEntryAt(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Machine) MapLeaves(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) (*Ref, error)
- func (ag *Machine) Merge(ctx context.Context, dst cadata.PostExister, src cadata.Getter, layers ...Ref) (*Ref, error)
- func (ag *Machine) NewBlobReader(ctx context.Context, s cadata.Getter, x Ref) (*Reader, error)
- func (ag *Machine) NewBlobWriter(s cadata.Poster) *TypedWriter
- func (ag *Machine) NewTreeReader(s cadata.Getter, x Ref) (*TreeReader, error)
- func (ag *Machine) NewTreeWriter(s cadata.PostExister) *TreeWriter
- func (ag *Machine) NewTypedWriter(s cadata.Poster, ty Type) *TypedWriter
- func (ag *Machine) Populate(ctx context.Context, store GetListDeleter, x Ref, dst AddExister) error
- func (ag *Machine) PostBlob(ctx context.Context, s cadata.Poster, r io.Reader) (*Ref, error)
- func (ag *Machine) PostTree(ctx context.Context, s cadata.PostExister, ents iter.Seq[TreeEntry]) (*Ref, error)
- func (ag *Machine) PostTreeMap(ctx context.Context, s cadata.PostExister, m map[string]Ref) (*Ref, error)
- func (ag *Machine) PostTreeSlice(ctx context.Context, dst cadata.PostExister, ents []TreeEntry) (*Ref, error)
- func (ag *Machine) PostTyped(ctx context.Context, s cadata.Poster, ty Type, r io.Reader) (*Ref, error)
- func (ag *Machine) ReadTreeFrom(r io.Reader) *TreeReader
- func (ag *Machine) ShardLeaves(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root Ref, ...) ([]Ref, error)
- func (ag *Machine) Sync(ctx context.Context, dst cadata.PostExister, src cadata.Getter, x Ref) error
- func (ag *Machine) Traverse(ctx context.Context, s cadata.Getter, sem *semaphore.Weighted, x Ref, ...) error
- func (ag *Machine) WalkRefs(ctx context.Context, s cadata.Getter, ref Ref, fn RefWalker) error
- func (ag *Machine) WalkTree(ctx context.Context, store cadata.Getter, ref Ref, f WalkTreeFunc) error
- 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 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 Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine holds a configuration, and caches. Machine configuration is immutable once it is created. Any cache state should be transparent to the user, so the Machine should appear stateless. Machines are thread-safe.
Creating a new Machine will perform better than using the default Machine when there are many concurrent operations being performed on unrelated filesystems, since the unreleated tasks won't be affecting the same cache.
Repeated lookups within a given filesystem will be much faster when rerun on the same machine. This is because each hop must be read from the store and decrypted, the decrypted plaintext will be cached by the machine.
func NewMachine ¶
func (*Machine) Compare ¶
func (ag *Machine) 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 (*Machine) FilterPaths ¶
func (ag *Machine) 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 (*Machine) GC ¶
func (ag *Machine) 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 (*Machine) GetAtPath ¶
func (ag *Machine) 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 (*Machine) GetBlobBytes ¶
func (ag *Machine) 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 (*Machine) GetTreeSlice ¶
func (ag *Machine) 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 (*Machine) GetTyped ¶
GetTyped retrieves the object in s at x. If x.Type != ty, ErrRefType is returned.
func (*Machine) MapEntries ¶
func (*Machine) MapEntryAt ¶
func (*Machine) Merge ¶
func (ag *Machine) 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 (*Machine) NewBlobReader ¶
func (*Machine) NewBlobWriter ¶
func (ag *Machine) NewBlobWriter(s cadata.Poster) *TypedWriter
func (*Machine) NewTreeReader ¶
func (*Machine) NewTreeWriter ¶
func (ag *Machine) NewTreeWriter(s cadata.PostExister) *TreeWriter
func (*Machine) NewTypedWriter ¶
func (ag *Machine) NewTypedWriter(s cadata.Poster, ty Type) *TypedWriter
NewTypedWriter returns a new writer for ty.
func (*Machine) Populate ¶
func (ag *Machine) Populate(ctx context.Context, store GetListDeleter, x Ref, dst AddExister) error
Populate adds everything reachable form x to dst
func (*Machine) PostTreeMap ¶
func (*Machine) PostTreeSlice ¶
func (*Machine) PostTyped ¶
func (ag *Machine) 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 (*Machine) ReadTreeFrom ¶
func (ag *Machine) ReadTreeFrom(r io.Reader) *TreeReader
func (*Machine) ShardLeaves ¶
func (*Machine) Sync ¶
func (ag *Machine) Sync(ctx context.Context, dst cadata.PostExister, src cadata.Getter, x Ref) error
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 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 Machine
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 Machine
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 Machine
func Merge ¶
func Merge(ctx context.Context, dst cadata.PostExister, src cadata.Getter, layers ...Ref) (*Ref, error)
Merge calls Merge on the default Machine
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