Documentation ¶
Index ¶
- Variables
- func FileHasher(path string) (string, error)
- func FilePathWalker(root string, index *Index, hasher PathHasher) filepath.WalkFunc
- func UploadBatch(diffFiles *Index, batchHash []string, toUpload *Index, store IndexStore, ...) error
- func UploadDifferences(localIndex, remoteIndex *Index, parallelLimit int, batchSize int, ...) error
- type Config
- type FileGetter
- type FileRepository
- type Index
- type IndexStore
- type Limiter
- type PathHasher
- type PathWalker
- type Sourcefile
Constants ¶
This section is empty.
Variables ¶
var ( // Verbose enables verbose logging in this package Verbose = false )
Functions ¶
func FileHasher ¶
FileHasher returns a hash of the contents of a file
func FilePathWalker ¶
func FilePathWalker(root string, index *Index, hasher PathHasher) filepath.WalkFunc
FilePathWalker is a PathWalker that accesses files on the disk when walking a directory tree
func UploadBatch ¶ added in v0.3.0
func UploadBatch(diffFiles *Index, batchHash []string, toUpload *Index, store IndexStore, limiter *Limiter, batchSize int, getFile FileGetter) error
This uploads batches given by UploadDifferences. The files in the batch are uploaded in parallel
func UploadDifferences ¶ added in v0.2.0
func UploadDifferences(localIndex, remoteIndex *Index, parallelLimit int, batchSize int, store IndexStore, getFile FileGetter) error
UploadDifferences will upload the files that are missing from the remote index
Types ¶
type Config ¶
Config defines the configuration for the whole tool
func NewConfigFromFile ¶
NewConfigFromFile generates a config object from a file
func NewConfigFromString ¶
NewConfigFromString generates a config object from the string
type FileGetter ¶ added in v0.2.0
type FileGetter func(p string) io.ReadCloser
FileGetter allows you to get the contents of a file
type FileRepository ¶
type FileRepository interface { // GetByKey retrieves the data at a certain location in your store GetByKey(key string) (io.Reader, error) // Save puts the data at a location in your store Save(key string, data io.Reader) error }
FileRepository allows you to access files in your remote location
type Index ¶
type Index struct { // Files maps the local file location to its metadata Files map[string]Sourcefile `yaml:"files"` }
Index holds all of the metadata for files backed up
func NewIndexFromRoot ¶
func NewIndexFromRoot( bucketRoot, path string, walker PathWalker, hasher PathHasher, ) (*Index, error)
NewIndexFromRoot creates a new Index populated from a filesystem directory
func (*Index) Add ¶ added in v0.2.0
func (i *Index) Add(f string, src Sourcefile)
Add a single source file to the index
type IndexStore ¶ added in v0.2.0
type IndexStore interface { // Save an indexed object to the specified location Save(key string, data io.Reader) error }
IndexStore allows you to persist indexed objects
type Limiter ¶ added in v0.3.0
type Limiter struct {
// contains filtered or unexported fields
}
Limiter object for limiting concurrency of go routines
type PathHasher ¶
PathHasher is a function that will hash the file at 'path' location
type PathWalker ¶
type PathWalker func(root string, index *Index, hasher PathHasher) filepath.WalkFunc
PathWalker is a function that can walk a directory tree and populate the Index that is passed in
type Sourcefile ¶
type Sourcefile struct { // Key is the location of this file in a bucket Key string `yaml:"key"` // Hash is the hashed value of the file contents Hash string `yaml:"hash"` }
Sourcefile represents the metadata for a single backed up file