Documentation ¶
Index ¶
- func AddContent(idx Index, path string, content []byte) (string, bool, error)
- func NewCachedFileSystem(src store.FileSystem, cache *FileSystem) (store.FileSystem, <-chan error)
- func NewIndex(fs store.RWFileSystem) (*index, error)
- type CachedFileSystem
- type FileSystem
- type Index
- type InvalidPathError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddContent ¶
Add the path+data to the index. Returns the content sum and true if the content already existed in the index, false otherwise.
func NewCachedFileSystem ¶
func NewCachedFileSystem(src store.FileSystem, cache *FileSystem) (store.FileSystem, <-chan error)
NewCacheFileSystem implements http.FileSystem and caches every request made to src in cache. The returned error channel passes back any errors which occur when files are being concurrently copied into the cache. Both src and cache must be content addressable using the same hashing scheme.
func NewIndex ¶
func NewIndex(fs store.RWFileSystem) (*index, error)
NewIndex creates a new file system index.
Types ¶
type CachedFileSystem ¶
type CachedFileSystem struct {
// contains filtered or unexported fields
}
CacheFileSystem is an implemetation of http.FileServer which assumes that both the cache and src is content addressable (i.e. file.Stat().Name() is a content hash). More efficient than the standard caching file system since any requested paths which aren't in the index are passed to the src and then their associated content is only downloaded if not already present.
func (*CachedFileSystem) Open ¶
Open implements FileSystem. If the required file isn't in the cache then the file is opened from the src, and then concurrently copied into the cache (with errors passed back on the filesystem error channel).
func (*CachedFileSystem) Wait ¶
func (c *CachedFileSystem) Wait() error
Wait blocks until any concurrent caching operations have been completed.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is a type which defines a content addressable filesystem.
func New ¶
func New(fs store.RWFileSystem) (*FileSystem, error)
New creates a new content addressable RWFileSystem.
func (*FileSystem) Create ¶
func (s *FileSystem) Create(ctx context.Context, path string) (io.WriteCloser, error)
Create a new file with path. We buffer the contents written to the io.WriteCloser so that the content can be hashed and then written to the underlying RWFileSystem.
type Index ¶
type Index interface { // Get returns the real path for the given filename, with true if and only // if the path exists in the index. Get(path string) (string, bool) // Add adds the path to the index, and returns the path to the file // and whether the path/content already exists. Add(path string, sum string) (bool, error) // Exists returns true of the sum is in the index. Exists(sum string) bool }
Index is an interface which contains methods for implementing a content addressable file system.
type InvalidPathError ¶
type InvalidPathError string
InvalidPathError is returned by cachine filesystem when a previous attempt has been made to fetch a file and failed. Prevents further access to the source.