cache

package
v0.0.0-...-4aaebde Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(c drive.Config) (drive.Client, error)

NewClient returns a Drive client which centralizes reading and writing to multiple Providers.

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

func (s *Drive) GetChunk(sha256sum []byte, f *shade.File) ([]byte, error)

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) GetConfig

func (s *Drive) GetConfig() drive.Config

GetConfig returns the config used to initialize this client.

func (*Drive) GetFile

func (s *Drive) GetFile(sha256sum []byte) ([]byte, error)

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

func (s *Drive) ListFiles() ([][]byte, error)

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

func (s *Drive) Local() bool

Local returns true only if all configured storage backends are local to this machine.

func (*Drive) Persistent

func (s *Drive) Persistent() bool

Persistent returns true if at least one configured storage backend is Persistent().

func (*Drive) PutChunk

func (s *Drive) PutChunk(sha256sum []byte, chunk []byte, f *shade.File) error

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

func (s *Drive) PutFile(sha256sum, f []byte) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL