amazon

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

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

NewClient returns an initialized Drive drive.Client object.

Types

type Drive

type Drive struct {
	// contains filtered or unexported fields
}

Drive is a representation of the Amazon Cloud storage system.

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 first gets the ID of the chunk with the named sha256sum, possibly from a cache. If then fetches the contents of the chunk from Drive.

The cache is especially helpful for shade.File objects, which are efficiently looked up on each call of ListFiles.

func (*Drive) GetConfig

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

GetConfig returns the Drive's associated Config object.

func (*Drive) GetFile

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

GetFile retrieves a file by sha256sum, as returned by ListFiles(). f should be marshalled JSON, and may be encrypted.

func (*Drive) ListFiles

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

ListFiles retrieves all of the File objects known to the client, and returns the corresponding sha256sum of the file object. Those may be passed to GetFile() to retrieve the corresponding shade.File.

func (*Drive) Local

func (s *Drive) Local() bool

Local returns whether the storage is local to this machine.

func (*Drive) Persistent

func (s *Drive) Persistent() bool

Persistent returns whether the storage is persistent across task restarts.

func (*Drive) PutChunk

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

PutChunk writes a chunk and returns its SHA-256 sum

func (*Drive) PutFile

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

PutFile writes the manifest describing a new file. f should be marshalled JSON, and may be encrypted.

type Endpoint

type Endpoint struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Endpoint provides the URLs the drive service should talk to.

It provides threadsafe methods to get the Content and Metadata URLs, to lookup new ones, and to keep them persistently up to date.

func NewEndpoint

func NewEndpoint(c *http.Client) (*Endpoint, error)

NewEndpoint returns an initialized Endpoint, or an error.

func (*Endpoint) ContentURL

func (ep *Endpoint) ContentURL() string

func (*Endpoint) GetEndpoint

func (ep *Endpoint) GetEndpoint() error

GetEndpoint requests the URL for this user to send queries to.

func (*Endpoint) MetadataURL

func (ep *Endpoint) MetadataURL() string

func (*Endpoint) RefreshEndpoint

func (ep *Endpoint) RefreshEndpoint()

refreshEndpoint periodically calls GetEndpoint This needs to be run every 3-5 days, per: https://developer.amazon.com/public/apis/experience/cloud-drive/content/account

TODO(asjoyner): cache this, and save 1 RPC for every invocation of throw

Jump to

Keyboard shortcuts

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