drive

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProvider

func RegisterProvider(name string, f clientCreator)

RegisterProvider declares that a provider with a given name exists and can be used via the calls below.

func TestChunkRoundTrip

func TestChunkRoundTrip(t *testing.T, c Client, numChunks uint64)

TestChunkRoundTrip allocates 100 random []byte, stores them in the client as chunks, then retrieves each one by its Sum and compares the bytes that are returned.

func TestFileRoundTrip

func TestFileRoundTrip(t *testing.T, c Client, numFiles uint64)

TestFileRoundTrip is a helper function, it allocates 100 random []byte, stores them in the provided client as files, retrieves them, and ensures all of the files were returned.

func TestParallelRoundTrip

func TestParallelRoundTrip(t *testing.T, c Client, n uint64)

TestParallelRoundTrip calls 10 copies of both test functions in parallel, to try to tickle race conditions in the implementation.

func ValidProvider

func ValidProvider(name string) bool

ValidProvider indicates whether a provider with the given name is registered.

Types

type Client

type Client interface {
	// ListFiles retrieves the sha256sum of all of the File objects known to the
	// client.  The elements of the slice may be passed to GetChunk() to retrieve
	// the corresponding shade.File object.  It will be marshaled JSON,
	// optionally encrypted.
	ListFiles() ([][]byte, error)

	// GetFile retrieves the metadata describing a shade.File.
	//
	// f should be marshalled JSON, and may be encrypted.  It differs only from
	// PutChunk in that ListFiles() will return these chunks.  sha256 is the hash
	// of the unencrypted shade.File object.  Nb: this leaks the a bit of
	// information about the file, but given that it contains the AES key, the
	// mtime of the shade.File, etc it should contain enough arbitrary data that
	// you can't infer anything meaningful from the SHA sum.
	GetFile(sha256 []byte) ([]byte, error)

	// PutFile writes the metadata describing a new file.
	// f should be marshalled JSON, and may be encrypted.  It differs only from
	// PutChunk in that ListFiles() will return these chunks.
	PutFile(sha256, chunk []byte) error

	// GetChunk retrieves a chunk with a given SHA-256 sum.  f is required for
	// files to support encryption.  It is used to store the AES key the chunk
	// and chunksum are encrypted with.
	GetChunk(sha256 []byte, f *shade.File) ([]byte, error)

	// PutChunk writes a chunk and returns its SHA-256 sum.  f is required for
	// files to support encryption.  It is used to store the AES key the chunk
	// and chunksum are encrypted with.
	PutChunk(sha256, chunk []byte, f *shade.File) error

	// GetConfig returns the drive.Config object used to initialize this client.
	// This is mostly helpful for debugging, to identify which Provider it is.
	GetConfig() Config

	// Local identifies the storage destination of the client to the caller.
	// If it returns false, code can expect that the content of this storage will
	// persist after the death of the binary, or the machine on which it is
	// running, or the continent on which it is located suffering a high altitude
	// EMP burst.
	Local() bool

	// Persistent identifies the storage durability of the client to the caller.
	// If it returns false, code can expect that the content of this storage will
	// persist after the death of the binary, but perhaps not the machine on
	// which it is running
	Persistent() bool
}

Client is a generic interface to a cloud storage backend.

func NewClient

func NewClient(c Config) (Client, error)

NewClient creates a new client of type provider with the provided config.

type Config

type Config struct {
	Provider      string
	OAuth         OAuthConfig
	FileParentID  string
	ChunkParentID string
	Write         bool
	MaxFiles      uint64
	MaxChunkBytes uint64
	RsaPublicKey  string
	RsaPrivateKey string
	Children      []Config
}

Config contains the configuration for the cloud drive being accessed.

type OAuthConfig

type OAuthConfig struct {
	ClientID     string
	ClientSecret string
	Scopes       []string
	TokenPath    string
}

OAuthConfig contains the OAuth configuration information.

Directories

Path Synopsis
Package cache is an interface to multiple storage backends for Shade.
Package cache is an interface to multiple storage backends for Shade.
Package encrypt is an interface to manage encrypted storage backends.
Package encrypt is an interface to manage encrypted storage backends.
Package fail is a test client.
Package fail is a test client.
Package local is a persistent local storage backend for Shade.
Package local is a persistent local storage backend for Shade.
Package memory is an in memory storage backend for Shade.
Package memory is an in memory storage backend for Shade.
Package win is a test client.
Package win is a test client.

Jump to

Keyboard shortcuts

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