storedriver

package
v0.1.0-beta-3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package storedriver is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGetRaw

func CheckGetRaw(raw *Raw, fileLength int64) error

CheckGetRaw check before get Raw

func CheckPutRaw

func CheckPutRaw(raw *Raw) error

CheckPutRaw check before put Raw

func CheckTrunc

func CheckTrunc(raw *Raw) error

CheckTrunc check before trunc file content

func Register

func Register(name string, builder DriverBuilder) error

Register defines an interface to register a driver with specified name. All drivers should call this function to register itself to the driverFactory.

Types

type Config

type Config struct {
	BaseDir string `yaml:"baseDir"`
}

type Driver

type Driver interface {

	// Get data from the storage based on raw information.
	// If the length<=0, the driver should return all data from the raw.offset.
	// Otherwise, just return the data which starts from raw.offset and the length is raw.length.
	Get(raw *Raw) (io.ReadCloser, error)

	// Get data from the storage based on raw information.
	// The data should be returned in bytes.
	// If the length<=0, the storage driver should return all data from the raw.offset.
	// Otherwise, just return the data which starts from raw.offset and the length is raw.length.
	GetBytes(raw *Raw) ([]byte, error)

	// Put the data into the storage with raw information.
	// The storage will get data from io.Reader as io stream.
	// If the offset>0, the storage driver should starting at byte raw.offset off.
	Put(raw *Raw, data io.Reader) error

	// PutBytes puts the data into the storage with raw information.
	// The data is passed in bytes.
	// If the offset>0, the storage driver should starting at byte raw.offset off.
	PutBytes(raw *Raw, data []byte) error

	// Remove the data from the storage based on raw information.
	Remove(raw *Raw) error

	// Stat determines whether the data exists based on raw information.
	// If that, and return some info that in the form of struct StorageInfo.
	// If not, return the ErrFileNotExist.
	Stat(raw *Raw) (*StorageInfo, error)

	// GetAvailSpace returns the available disk space in B.
	GetAvailSpace() (unit.Bytes, error)

	// GetTotalAndFreeSpace
	GetTotalAndFreeSpace() (unit.Bytes, unit.Bytes, error)

	// GetTotalSpace
	GetTotalSpace() (unit.Bytes, error)

	// Walk walks the file tree rooted at root which determined by raw.Bucket and raw.Key,
	// calling walkFn for each file or directory in the tree, including root.
	Walk(raw *Raw) error

	// CreateBaseDir
	CreateBaseDir() error

	// GetPath
	GetPath(raw *Raw) string

	// MoveFile
	MoveFile(src string, dst string) error

	// Exits
	Exits(raw *Raw) bool

	// GetHomePath
	GetHomePath() string
}

Driver defines an interface to manage the data stored in the driver.

NOTE: It is recommended that the lock granularity of the driver should be in piece. That means that the storage driver could read and write the different pieces of the same file concurrently.

func Get

func Get(name string) (Driver, bool)

Get a store from manager with specified name.

type DriverBuilder

type DriverBuilder func(cfg *Config) (Driver, error)

DriverBuilder is a function that creates a new storage driver plugin instant with the giving Config.

type MockDriver

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

MockDriver is a mock of Driver interface.

func NewMockDriver

func NewMockDriver(ctrl *gomock.Controller) *MockDriver

NewMockDriver creates a new mock instance.

func (*MockDriver) CreateBaseDir

func (m *MockDriver) CreateBaseDir() error

CreateBaseDir mocks base method.

func (*MockDriver) EXPECT

func (m *MockDriver) EXPECT() *MockDriverMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDriver) Exits

func (m *MockDriver) Exits(arg0 *Raw) bool

Exits mocks base method.

func (*MockDriver) Get

func (m *MockDriver) Get(arg0 *Raw) (io.ReadCloser, error)

Get mocks base method.

func (*MockDriver) GetAvailSpace

func (m *MockDriver) GetAvailSpace() (unit.Bytes, error)

GetAvailSpace mocks base method.

func (*MockDriver) GetBytes

func (m *MockDriver) GetBytes(arg0 *Raw) ([]byte, error)

GetBytes mocks base method.

func (*MockDriver) GetHomePath

func (m *MockDriver) GetHomePath() string

GetHomePath mocks base method.

func (*MockDriver) GetPath

func (m *MockDriver) GetPath(arg0 *Raw) string

GetPath mocks base method.

func (*MockDriver) GetTotalAndFreeSpace

func (m *MockDriver) GetTotalAndFreeSpace() (unit.Bytes, unit.Bytes, error)

GetTotalAndFreeSpace mocks base method.

func (*MockDriver) GetTotalSpace

func (m *MockDriver) GetTotalSpace() (unit.Bytes, error)

GetTotalSpace mocks base method.

func (*MockDriver) MoveFile

func (m *MockDriver) MoveFile(arg0, arg1 string) error

MoveFile mocks base method.

func (*MockDriver) Put

func (m *MockDriver) Put(arg0 *Raw, arg1 io.Reader) error

Put mocks base method.

func (*MockDriver) PutBytes

func (m *MockDriver) PutBytes(arg0 *Raw, arg1 []byte) error

PutBytes mocks base method.

func (*MockDriver) Remove

func (m *MockDriver) Remove(arg0 *Raw) error

Remove mocks base method.

func (*MockDriver) Stat

func (m *MockDriver) Stat(arg0 *Raw) (*StorageInfo, error)

Stat mocks base method.

func (*MockDriver) Walk

func (m *MockDriver) Walk(arg0 *Raw) error

Walk mocks base method.

type MockDriverMockRecorder

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

MockDriverMockRecorder is the mock recorder for MockDriver.

func (*MockDriverMockRecorder) CreateBaseDir

func (mr *MockDriverMockRecorder) CreateBaseDir() *gomock.Call

CreateBaseDir indicates an expected call of CreateBaseDir.

func (*MockDriverMockRecorder) Exits

func (mr *MockDriverMockRecorder) Exits(arg0 interface{}) *gomock.Call

Exits indicates an expected call of Exits.

func (*MockDriverMockRecorder) Get

func (mr *MockDriverMockRecorder) Get(arg0 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockDriverMockRecorder) GetAvailSpace

func (mr *MockDriverMockRecorder) GetAvailSpace() *gomock.Call

GetAvailSpace indicates an expected call of GetAvailSpace.

func (*MockDriverMockRecorder) GetBytes

func (mr *MockDriverMockRecorder) GetBytes(arg0 interface{}) *gomock.Call

GetBytes indicates an expected call of GetBytes.

func (*MockDriverMockRecorder) GetHomePath

func (mr *MockDriverMockRecorder) GetHomePath() *gomock.Call

GetHomePath indicates an expected call of GetHomePath.

func (*MockDriverMockRecorder) GetPath

func (mr *MockDriverMockRecorder) GetPath(arg0 interface{}) *gomock.Call

GetPath indicates an expected call of GetPath.

func (*MockDriverMockRecorder) GetTotalAndFreeSpace

func (mr *MockDriverMockRecorder) GetTotalAndFreeSpace() *gomock.Call

GetTotalAndFreeSpace indicates an expected call of GetTotalAndFreeSpace.

func (*MockDriverMockRecorder) GetTotalSpace

func (mr *MockDriverMockRecorder) GetTotalSpace() *gomock.Call

GetTotalSpace indicates an expected call of GetTotalSpace.

func (*MockDriverMockRecorder) MoveFile

func (mr *MockDriverMockRecorder) MoveFile(arg0, arg1 interface{}) *gomock.Call

MoveFile indicates an expected call of MoveFile.

func (*MockDriverMockRecorder) Put

func (mr *MockDriverMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call

Put indicates an expected call of Put.

func (*MockDriverMockRecorder) PutBytes

func (mr *MockDriverMockRecorder) PutBytes(arg0, arg1 interface{}) *gomock.Call

PutBytes indicates an expected call of PutBytes.

func (*MockDriverMockRecorder) Remove

func (mr *MockDriverMockRecorder) Remove(arg0 interface{}) *gomock.Call

Remove indicates an expected call of Remove.

func (*MockDriverMockRecorder) Stat

func (mr *MockDriverMockRecorder) Stat(arg0 interface{}) *gomock.Call

Stat indicates an expected call of Stat.

func (*MockDriverMockRecorder) Walk

func (mr *MockDriverMockRecorder) Walk(arg0 interface{}) *gomock.Call

Walk indicates an expected call of Walk.

type Raw

type Raw struct {
	Bucket    string
	Key       string
	Offset    int64
	Length    int64
	Trunc     bool
	TruncSize int64
	Append    bool
	WalkFn    filepath.WalkFunc
}

Raw identifies a piece of data uniquely. If the length<=0, it represents all data.

type StorageInfo

type StorageInfo struct {
	Path       string    // file path
	Size       int64     // file size
	CreateTime time.Time // create time
	ModTime    time.Time // modified time
}

StorageInfo includes partial meta information of the data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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