Documentation ¶
Index ¶
- func RegisterProvider(name string, f clientCreator)
- func TestChunkRoundTrip(t *testing.T, c Client, numChunks uint64)
- func TestFileRoundTrip(t *testing.T, c Client, numFiles uint64)
- func TestParallelRoundTrip(t *testing.T, c Client, n uint64)
- func ValidProvider(name string) bool
- type Client
- type Config
- type OAuthConfig
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 ¶
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 ¶
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 ¶
TestParallelRoundTrip calls 10 copies of both test functions in parallel, to try to tickle race conditions in the implementation.
func ValidProvider ¶
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.
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. |