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 SizeOf(x Ref) uint64
- func Sync(ctx context.Context, dst cadata.Store, src cadata.Getter, x Ref) 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, s GetPoster, left, right Ref) (*Diff, error)
- func (ag *Agent) Concat(ctx context.Context, store cadata.Store, layers ...Ref) (*Ref, error)
- func (ag *Agent) FilterPaths(ctx context.Context, s GetPoster, root Ref, f func(string) bool) (*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) GetTree(ctx context.Context, store cadata.Getter, ref Ref) (*Tree, error)
- func (ag *Agent) GetTyped(ctx context.Context, s cadata.Getter, ty Type, x Ref) (*Reader, error)
- func (ag *Agent) MapBlobs(ctx context.Context, s GetPoster, root Ref, f BlobMapper) (*Ref, error)
- func (ag *Agent) MapEntries(ctx context.Context, s GetPoster, root Ref, f TreeEntryMapper) (*Ref, error)
- func (ag *Agent) MapEntryAt(ctx context.Context, s GetPoster, root Ref, p string, f TreeEntryMapper) (*Ref, error)
- func (ag *Agent) MapLeaves(ctx context.Context, s GetPoster, root Ref, f RefMapper) (*Ref, error)
- func (ag *Agent) Merge(ctx context.Context, store GetPoster, layers ...Ref) (*Ref, 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.Poster) *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, store cadata.Poster, t Tree) (*Ref, error)
- func (ag *Agent) PostTreeEntries(ctx context.Context, s cadata.Poster, ents []TreeEntry) (*Ref, error)
- func (ag *Agent) PostTreeMap(ctx context.Context, s cadata.Poster, m map[string]Ref) (*Ref, error)
- func (ag *Agent) PostTyped(ctx context.Context, s cadata.Poster, ty Type, r io.Reader) (*Ref, error)
- func (ag *Agent) ShardLeaves(ctx context.Context, s GetPoster, root Ref, n int) ([]Ref, error)
- func (ag *Agent) Sync(ctx context.Context, dst cadata.Store, 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 GetPoster
- type Option
- type PostLister
- type Reader
- type Ref
- func FilterPaths(ctx context.Context, s GetPoster, root Ref, f func(string) bool) (*Ref, error)
- func GetAtPath(ctx context.Context, store cadata.Getter, ref Ref, subpath string) (*Ref, error)
- func MapBlobs(ctx context.Context, s GetPoster, root Ref, f BlobMapper) (*Ref, error)
- func MapEntryAt(ctx context.Context, s GetPoster, root Ref, p string, f TreeEntryMapper) (*Ref, error)
- func MapLeaves(ctx context.Context, s GetPoster, root Ref, f RefMapper) (*Ref, error)
- func Merge(ctx context.Context, store GetPoster, layers ...Ref) (*Ref, error)
- func PostBlob(ctx context.Context, s cadata.Poster, r io.Reader) (*Ref, error)
- func PostTree(ctx context.Context, store cadata.Poster, t Tree) (*Ref, error)
- func PostTreeEntries(ctx context.Context, s cadata.Poster, ents []TreeEntry) (*Ref, error)
- func PostTreeMap(ctx context.Context, s cadata.Poster, m map[string]Ref) (*Ref, error)
- func PostTyped(ctx context.Context, s cadata.Poster, ty Type, r io.Reader) (*Ref, error)
- func ShardLeaves(ctx context.Context, s GetPoster, root Ref, n int) ([]Ref, error)
- type RefMapper
- type RefWalker
- type Traverser
- type Tree
- 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 ¶
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.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) Compare ¶
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, s GetPoster, 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) GetTree ¶
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 ¶
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)
func (*Agent) NewBlobWriter ¶
func (ag *Agent) NewBlobWriter(s cadata.Poster) *TypedWriter
func (*Agent) NewTreeReader ¶
func (*Agent) NewTreeWriter ¶
func (ag *Agent) NewTreeWriter(s cadata.Poster) *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) PostTreeEntries ¶
func (*Agent) PostTreeMap ¶
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) 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 ¶
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 MapEntryAt ¶
func MapEntryAt(ctx context.Context, s GetPoster, root Ref, p string, f TreeEntryMapper) (*Ref, error)
MapEntryAt calls MapEntryAt on the default Agent
func PostTreeEntries ¶
func PostTreeMap ¶
func ShardLeaves ¶
ShardLeaves calls ShardLeaves on the default Agent
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 Tree ¶
type Tree struct {
Entries []TreeEntry
}
Tree is a directory of entries to other trees or blobs Each entry in a tree has a unique name.
func GetTree ¶
GetTree retreives the tree in store at Ref if it exists. If ref.Type != TypeTree ErrRefType is returned.
func (*Tree) Lookup ¶
Lookup returns the entry in the tree with name if it exists, or nil if it does not.
func (*Tree) MarshalText ¶
func (*Tree) UnmarshalText ¶
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
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