storage

package
v0.0.0-...-e03385f Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package storage provides methods related to storage handling

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Region string `json:"region"`
	Bucket string `json:"bucket"`
	Key    string `json:"key"`
}

Config config holds the information related to storage configs

type FileStorage

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

FileStorage implements the Storage interface

func NewFileStorage

func NewFileStorage(fileName string) (*FileStorage, error)

NewFileStorage returns a new file storage with fullPath

func (*FileStorage) IsExist

func (f *FileStorage) IsExist() bool

IsExist implements storage interface returns whether the file already exists or not

func (*FileStorage) Read

func (f *FileStorage) Read() ([]byte, error)

Read implements the storage interface Reads the bytes from the file storage

func (*FileStorage) Write

func (f *FileStorage) Write(data []byte) (int, error)

Write implements the storage interface Writes the given data bytes at the fileLocation

type MockStorage

type MockStorage struct {
	mock.Mock
}

MockStorage provides mock Storage implementation

func (*MockStorage) IsExist

func (m *MockStorage) IsExist() bool

IsExist implements the Storage interface

func (*MockStorage) Read

func (m *MockStorage) Read() ([]byte, error)

Read implements the storage interface

func (*MockStorage) Write

func (m *MockStorage) Write(data []byte) (int, error)

Write implements the Storage interface

type S3Storage

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

S3Storage is the wrapper for the aws s3 client

func NewS3Storage

func NewS3Storage(s3Config *Config, cfgs ...*aws.Config) (*S3Storage, error)

NewS3Storage constructs a new s3 client

func (*S3Storage) IsExist

func (storage *S3Storage) IsExist() bool

IsExist retrieves metadata from an object to verify whether object exists

func (*S3Storage) Read

func (storage *S3Storage) Read() ([]byte, error)

Read retrieves an object from s3

func (*S3Storage) Write

func (storage *S3Storage) Write(data []byte) (int, error)

Write puts an object into S3.

type Storage

type Storage interface {
	IsExist() bool

	Write(data []byte) (int, error)

	Read() ([]byte, error)
}

Storage interface provides all methods required for read/write/checkExistence of any snapshot or diff

func NewStorage

func NewStorage(key string) (Storage, error)

NewStorage gives the current implementation of Storage returns storage object if initialised properly throws error if storage cannot be initialised Default it returns file storage

Jump to

Keyboard shortcuts

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