storedriver

package
v2.0.2-rc.5 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: Apache-2.0 Imports: 13 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)

func RegisterPlugin added in v2.0.2

func RegisterPlugin(name string, builder DriverBuilder) error

RegisterPlugin 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)

	// GetBytes 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)

	// GetFreeSpace returns the free disk space in B.
	GetFreeSpace() (unit.Bytes, error)

	// GetTotalAndFreeSpace returns the total and free disk space in B.
	GetTotalAndFreeSpace() (unit.Bytes, unit.Bytes, error)

	// GetTotalSpace returns the total disk space in B.
	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 create base dir
	CreateBaseDir() error

	// GetPath get path of raw
	GetPath(raw *Raw) string

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

	// Exits check if raw exists
	Exits(raw *Raw) bool

	// GetBaseDir returns base dir
	GetBaseDir() 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 GetPlugin added in v2.0.2

func GetPlugin(name string) (Driver, bool)

GetPlugin 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.

func Get

func Get(name string) DriverBuilder

Get return a storage manager from manager with specified name.

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) GetBaseDir added in v2.0.2

func (m *MockDriver) GetBaseDir() string

GetBaseDir mocks base method.

func (*MockDriver) GetBytes

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

GetBytes mocks base method.

func (*MockDriver) GetFreeSpace

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

GetFreeSpace 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) GetBaseDir added in v2.0.2

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

GetBaseDir indicates an expected call of GetBaseDir.

func (*MockDriverMockRecorder) GetBytes

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

GetBytes indicates an expected call of GetBytes.

func (*MockDriverMockRecorder) GetFreeSpace

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

GetFreeSpace indicates an expected call of GetFreeSpace.

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 `json:"bucket"`
	Key       string `json:"key"`
	Offset    int64  `json:"offset"`
	Length    int64  `json:"length"`
	Trunc     bool   `json:"trunc"`
	TruncSize int64  `json:"trunc_size"`
	Append    bool   `json:"append"`
	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    `json:"path"`        // file path
	Size       int64     `json:"size"`        // file size
	CreateTime time.Time `json:"create_time"` // create time
	ModTime    time.Time `json:"mod_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