storage

package
v0.0.0-...-7234002 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MockErrNoSuchKey = errors.New("The specified key does not exist.")

Functions

This section is empty.

Types

type FileStorage

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

FileStorage stores data locally on disk in some directory.

func NewFileStorage

func NewFileStorage(root string) *FileStorage

func (*FileStorage) Create

func (fs *FileStorage) Create() error

func (*FileStorage) Exists

func (fs *FileStorage) Exists() (bool, error)

func (*FileStorage) GetReader

func (fs *FileStorage) GetReader(key string) (io.Reader, error)

func (*FileStorage) IsNotExist

func (fs *FileStorage) IsNotExist(err error) bool

func (*FileStorage) PutReader

func (fs *FileStorage) PutReader(key string, r io.Reader) (length int, err error)

func (*FileStorage) Size

func (fs *FileStorage) Size(key string) (int, error)

type HeadError

type HeadError struct {
	Response *http.Response
	Err      error
}

func (*HeadError) Error

func (e *HeadError) Error() string

type MockReaderWrapper

type MockReaderWrapper func(r io.Reader) io.Reader

type MockRequestFault

type MockRequestFault func(key string) error

type MockStorage

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

MockStorage is used for testing; data is stored in memory in a map.

func NewMockStorage

func NewMockStorage() *MockStorage

func (*MockStorage) ClearReaderWrappers

func (s *MockStorage) ClearReaderWrappers()

ClearReaderWrappers clears any reader callbacks that have been added by InjectReaderWrapper.

func (*MockStorage) ClearRequestFaults

func (s *MockStorage) ClearRequestFaults()

ClearRequestFaults clears any request callbacks that have been added by InjectRequestFault.

func (*MockStorage) Create

func (s *MockStorage) Create() error

func (*MockStorage) Exists

func (s *MockStorage) Exists() (bool, error)

func (*MockStorage) GetReader

func (s *MockStorage) GetReader(key string) (r io.Reader, err error)

func (*MockStorage) InjectReaderWrapper

func (s *MockStorage) InjectReaderWrapper(fn MockReaderWrapper)

InjectReaderWrapper adds a callback which gets called when an io.Reader is returned by GetReader. This func should wrap that Reader or return it unchanged.

func (*MockStorage) InjectRequestFault

func (s *MockStorage) InjectRequestFault(fn MockRequestFault)

InjectRequestFault adds a callback which gets called when a key is requested by GetReader. This func should return an error or nil.

func (*MockStorage) IsNotExist

func (s *MockStorage) IsNotExist(err error) bool

func (*MockStorage) PutReader

func (s *MockStorage) PutReader(key string, r io.Reader) (int, error)

func (*MockStorage) PutString

func (s *MockStorage) PutString(key, value string)

Put allows easy writing to a key for tests.

func (*MockStorage) Size

func (s *MockStorage) Size(key string) (int, error)

type S3Connection

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

S3Connection stores data remotely to a private S3 bucket.

func NewS3Connection

func NewS3Connection(region, bucket, accessKey, secretKey string) (*S3Connection, error)

NewS3Connection connects to S3 in the given region, using the AWS credentials provided. If accessKey / secretKey are blank, will try to either read them from ENV[AWS_CREDENTIAL_FILE] (defaults to $HOME/.aws/credentials) or use the values in ENV[AWS_ACCESS_KEY] and ENV[AWS_SECRET_KEY].

func (*S3Connection) Create

func (c *S3Connection) Create() error

func (*S3Connection) Exists

func (c *S3Connection) Exists() (bool, error)

func (*S3Connection) GetReader

func (c *S3Connection) GetReader(key string) (io.Reader, error)

func (*S3Connection) IsNotExist

func (c *S3Connection) IsNotExist(err error) bool

func (*S3Connection) PutReader

func (c *S3Connection) PutReader(key string, r io.Reader) (length int, err error)

func (*S3Connection) Size

func (c *S3Connection) Size(key string) (int, error)

Jump to

Keyboard shortcuts

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