Documentation
¶
Overview ¶
Package cache is an interface to multiple storage backends for Shade. It centralizes the implementation of reading and writing to multiple drive.Clients.
Index ¶
- func NewClient(c drive.Config) (drive.Client, error)
- type Drive
- func (s *Drive) Debug()
- func (s *Drive) GetChunk(sha256sum []byte, f *shade.File) ([]byte, error)
- func (s *Drive) GetConfig() drive.Config
- func (s *Drive) GetFile(sha256sum []byte) ([]byte, error)
- func (s *Drive) ListFiles() ([][]byte, error)
- func (s *Drive) Local() bool
- func (s *Drive) Persistent() bool
- func (s *Drive) PutChunk(sha256sum []byte, chunk []byte, f *shade.File) error
- func (s *Drive) PutFile(sha256sum, f []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Drive ¶
type Drive struct {
// contains filtered or unexported fields
}
Drive implements the drive.Client interface by reading and writing to the slice of drive.Client interfaces it was provided. It can return a config which describes only its name.
If any of its clients are not Local(), it reports itself as not Local() by returning false. If any of its clients are Persistent(), it requires writes to at least one of those backends to succeed, and reports itself as Persistent().
func (*Drive) Debug ¶
func (s *Drive) Debug()
Debug enables debug statements to STDERR for non-critical failures to read or write from clients.
func (*Drive) GetChunk ¶
GetChunk retrieves a chunk with a given SHA-256 sum. It will be returned from the first client in the slice of structs that returns the chunk.
func (*Drive) GetFile ¶
GetFile retrieves a file with a given SHA-256 sum. It will be returned from the first client in the slice of structs that returns the chunk.
func (*Drive) ListFiles ¶
ListFiles retrieves all of the File objects known to all of the provided clients. The return is a list of sha256sums of the file object. The keys may be passed to GetChunk() to retrieve the corresponding shade.File.
func (*Drive) Local ¶
Local returns true only if all configured storage backends are local to this machine.
func (*Drive) Persistent ¶
Persistent returns true if at least one configured storage backend is Persistent().
func (*Drive) PutChunk ¶
PutChunk writes a chunk associated with a SHA-256 sum. It will attempt to write to all shade backends configured to Write. If any backends are Persistent, it returns an error if all Persistent backends fail to write.