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 ChunkLister
- type Drive
- 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) NewChunkLister() drive.ChunkLister
- 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
- func (s *Drive) ReleaseChunk(sha256sum []byte) error
- func (s *Drive) ReleaseFile(sha256sum []byte) error
- func (s *Drive) Warm(chunks [][]byte, f *shade.File)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChunkLister ¶
type ChunkLister struct {
// contains filtered or unexported fields
}
ChunkLister allows iterating the chunks in all child clients.
func (*ChunkLister) Err ¶
func (c *ChunkLister) Err() error
Err returns the error encountered, if any.
func (*ChunkLister) Next ¶
func (c *ChunkLister) Next() bool
Next advances the iterator returned by Sha256.
It attempts to see if the current client has another Sha256 to provide. When a client is exhausted it advances to the next client. If an Err is encountered, iteration stops and Err() is propagated back to the caller.
func (*ChunkLister) Sha256 ¶
func (c *ChunkLister) Sha256() []byte
Sha256 returns the chunk pointed to by the pointer.
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) 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) NewChunkLister ¶
func (s *Drive) NewChunkLister() drive.ChunkLister
NewChunkLister returns an iterator which will return all of the chunks known to all child clients.
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.
func (*Drive) PutFile ¶
PutFile writes the metadata describing a new file. It will be written to all shade backends configured to Write. If any backends are Persistent, it returns an error if all Persistent backends fail to write. f should be marshalled JSON, and may be encrypted.
func (*Drive) ReleaseChunk ¶
ReleaseChunk calls ReleaseChunk on each of the provided clients in sequence. No errors are returned from child clients.
func (*Drive) ReleaseFile ¶
ReleaseFile calls ReleaseFile on each of the provided clients in sequence. No errors are returned from child clients.