Documentation ¶
Overview ¶
Package storedriver is a generated GoMock package.
Index ¶
- func CheckGetRaw(raw *Raw, fileLength int64) error
- func CheckPutRaw(raw *Raw) error
- func CheckTrunc(raw *Raw) error
- func Register(name string, builder DriverBuilder) error
- type Config
- type Driver
- type DriverBuilder
- type MockDriver
- func (m *MockDriver) CreateBaseDir() error
- func (m *MockDriver) EXPECT() *MockDriverMockRecorder
- func (m *MockDriver) Exits(arg0 *Raw) bool
- func (m *MockDriver) Get(arg0 *Raw) (io.ReadCloser, error)
- func (m *MockDriver) GetBytes(arg0 *Raw) ([]byte, error)
- func (m *MockDriver) GetFreeSpace() (unit.Bytes, error)
- func (m *MockDriver) GetHomePath() string
- func (m *MockDriver) GetPath(arg0 *Raw) string
- func (m *MockDriver) GetTotalAndFreeSpace() (unit.Bytes, unit.Bytes, error)
- func (m *MockDriver) GetTotalSpace() (unit.Bytes, error)
- func (m *MockDriver) MoveFile(arg0, arg1 string) error
- func (m *MockDriver) Put(arg0 *Raw, arg1 io.Reader) error
- func (m *MockDriver) PutBytes(arg0 *Raw, arg1 []byte) error
- func (m *MockDriver) Remove(arg0 *Raw) error
- func (m *MockDriver) Stat(arg0 *Raw) (*StorageInfo, error)
- func (m *MockDriver) Walk(arg0 *Raw) error
- type MockDriverMockRecorder
- func (mr *MockDriverMockRecorder) CreateBaseDir() *gomock.Call
- func (mr *MockDriverMockRecorder) Exits(arg0 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) Get(arg0 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) GetBytes(arg0 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) GetFreeSpace() *gomock.Call
- func (mr *MockDriverMockRecorder) GetHomePath() *gomock.Call
- func (mr *MockDriverMockRecorder) GetPath(arg0 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) GetTotalAndFreeSpace() *gomock.Call
- func (mr *MockDriverMockRecorder) GetTotalSpace() *gomock.Call
- func (mr *MockDriverMockRecorder) MoveFile(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) PutBytes(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) Remove(arg0 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) Stat(arg0 interface{}) *gomock.Call
- func (mr *MockDriverMockRecorder) Walk(arg0 interface{}) *gomock.Call
- type Raw
- type StorageInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckGetRaw ¶
CheckGetRaw check before get Raw
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 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) // GetFreeSpace returns the available disk space in B. GetFreeSpace() (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.
type DriverBuilder ¶
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) Get ¶
func (m *MockDriver) Get(arg0 *Raw) (io.ReadCloser, error)
Get 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) 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 ¶
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) Stat ¶
func (m *MockDriver) Stat(arg0 *Raw) (*StorageInfo, error)
Stat 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) 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) 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 `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.