Documentation
¶
Index ¶
- Variables
- func DeleteIfExists(ctx context.Context, st Storage, name string) (err *mft.Error)
- func Load(ctx context.Context, s Storage, fileName string, v Storable) (err *mft.Error)
- func LoadIfExists(ctx context.Context, s Storage, fileName string, v Storable, doFill CheckFunc) (ok bool, err *mft.Error)
- func LoadObject(ssr StorableSaveReady) (err *mft.Error)
- func Save(ctx context.Context, s Storage, fileName string, v Storable) (err *mft.Error)
- func SaveExtend(ctx context.Context, s Storage, fileName string, v Storable, ...) (err *mft.Error)
- func SaveObject(ssr StorableSaveReady) (err *mft.Error)
- type CheckFunc
- type CreateFileSorageParams
- type DoFunc
- type DoubleSaveSorage
- func (s *DoubleSaveSorage) Delete(ctx context.Context, name string) *mft.Error
- func (s *DoubleSaveSorage) Exists(ctx context.Context, name string) (ok bool, err *mft.Error)
- func (s *DoubleSaveSorage) Get(ctx context.Context, name string) (body []byte, err *mft.Error)
- func (s *DoubleSaveSorage) MkDirIfNotExists(ctx context.Context, name string) *mft.Error
- func (s *DoubleSaveSorage) Rename(ctx context.Context, oldName string, newName string) *mft.Error
- func (s *DoubleSaveSorage) Save(ctx context.Context, name string, body []byte) *mft.Error
- type FileSorage
- func (s *FileSorage) Delete(ctx context.Context, name string) *mft.Error
- func (s *FileSorage) Exists(ctx context.Context, name string) (ok bool, err *mft.Error)
- func (s *FileSorage) Get(ctx context.Context, name string) (body []byte, err *mft.Error)
- func (s *FileSorage) MkDirIfNotExists(ctx context.Context, name string) *mft.Error
- func (s *FileSorage) Rename(ctx context.Context, oldName string, newName string) *mft.Error
- func (s *FileSorage) Save(ctx context.Context, name string, body []byte) *mft.Error
- type Generator
- type GeneratorInfo
- type MapSorage
- func (s *MapSorage) Delete(ctx context.Context, name string) *mft.Error
- func (s *MapSorage) Exists(ctx context.Context, name string) (ok bool, err *mft.Error)
- func (s *MapSorage) Get(ctx context.Context, name string) (body []byte, err *mft.Error)
- func (s *MapSorage) MkDirIfNotExists(ctx context.Context, name string) *mft.Error
- func (s *MapSorage) Rename(ctx context.Context, oldName string, newName string) *mft.Error
- func (s *MapSorage) Save(ctx context.Context, name string, body []byte) *mft.Error
- type Mount
- type SaveObjectProto
- func (sp *SaveObjectProto) DataLock(ctx context.Context) bool
- func (sp *SaveObjectProto) DataRLock(ctx context.Context) bool
- func (sp *SaveObjectProto) DataRUnlock()
- func (sp *SaveObjectProto) DataUnlock()
- func (sp *SaveObjectProto) RvGetLast() int64
- func (sp *SaveObjectProto) RvGetStor() int64
- func (sp *SaveObjectProto) RvSetStor(rv int64)
- func (sp *SaveObjectProto) StorLock(ctx context.Context) bool
- func (sp *SaveObjectProto) StorUnlock()
- type SaveProto
- type Storable
- type StorableSaveReady
- type Storage
- type StorageType
- type ZipSaveSorage
- func (s *ZipSaveSorage) Delete(ctx context.Context, name string) *mft.Error
- func (s *ZipSaveSorage) Exists(ctx context.Context, name string) (ok bool, err *mft.Error)
- func (s *ZipSaveSorage) Get(ctx context.Context, name string) (body []byte, err *mft.Error)
- func (s *ZipSaveSorage) MkDirIfNotExists(ctx context.Context, name string) *mft.Error
- func (s *ZipSaveSorage) Path(name string) string
- func (s *ZipSaveSorage) Rename(ctx context.Context, oldName string, newName string) *mft.Error
- func (s *ZipSaveSorage) Save(ctx context.Context, name string, body []byte) (err *mft.Error)
Constants ¶
This section is empty.
Variables ¶
var Errors map[int]string = map[int]string{
10000000: "MapSorage: not found name: `%v`",
10000001: "MapSorage: name exists: `%v`",
10000002: "File: error: `%v`",
10000003: "Mkdir error: path: `%v`",
10001000: "Cluster.Create: Lock mutex fail wait",
10001001: "Cluster.Create: storage type `%v` is not exists",
10001002: "Cluster.Create: mount `%v` is not exists",
10001100: "SaveExtend: Storage is nil",
10001101: "SaveExtend: Storable StorLock fail",
10001102: "SaveExtend: Storable DataRLock fail",
10001103: "SaveExtend: Storable ToBytes fail",
10001104: "SaveExtend: doBeforeGetData fail",
10001105: "SaveExtend: doBeforeSave fail",
10001106: "SaveExtend: doAfterSave fail",
10001107: "SaveExtend: Storage Save to storage `%v` fail",
10001120: "LoadIfExists: Storage is nil",
10001121: "Load: File `%v` does not exists",
10001122: "LoadIfExists: Storable StorLock fail",
10001123: "LoadIfExists: Storage check file `%v` exists fail",
10001124: "LoadIfExists: Storage get file `%v` fail",
10001125: "LoadIfExists: Storable FromBytes from file `%v` fail",
10001126: "LoadIfExists: Storable DataLock fail",
10001127: "LoadIfExists: doFill Check fail",
}
Errors codes and description
Functions ¶
func DeleteIfExists ¶
DeleteIfExists delete file if exists
func LoadIfExists ¶ added in v0.0.4
func LoadObject ¶ added in v0.0.8
func LoadObject(ssr StorableSaveReady) (err *mft.Error)
func SaveExtend ¶ added in v0.0.4
func SaveObject ¶ added in v0.0.8
func SaveObject(ssr StorableSaveReady) (err *mft.Error)
Types ¶
type CreateFileSorageParams ¶
type CreateFileSorageParams struct {
Folder string `json:"folder"`
}
CreateFileSorageParams params for create file storage
type DoubleSaveSorage ¶
type DoubleSaveSorage struct {
// contains filtered or unexported fields
}
DoubleSaveSorage - storage that saves to Map (memory)
func CreateDoubleSaveSorage ¶
func CreateDoubleSaveSorage(storage Storage) *DoubleSaveSorage
CreateDoubleSaveSorage - creates double_save_storage storange
func (*DoubleSaveSorage) MkDirIfNotExists ¶
MkDirIfNotExists make directory
type FileSorage ¶
FileSorage file on disk profider
func CreateFileSorage ¶
func CreateFileSorage(ctx context.Context, params CreateFileSorageParams) (*FileSorage, *mft.Error)
CreateFileSorage creates simple FileOnDisk with perms 0760 & 0660
func (*FileSorage) MkDirIfNotExists ¶
MkDirIfNotExists make directory
type Generator ¶
type Generator struct {
GeneratorInfo GeneratorInfo
// contains filtered or unexported fields
}
Generator - storage cluster
func CreateGenerator ¶
func CreateGenerator(generatorInfo GeneratorInfo, compressor *compress.Generator) *Generator
CreateGenerator create storage cluster
type GeneratorInfo ¶
type MapSorage ¶
type MapSorage struct {
// contains filtered or unexported fields
}
MapSorage - storage that saves to Map (memory)
func (*MapSorage) MkDirIfNotExists ¶
MkDirIfNotExists make directory
type Mount ¶
type Mount struct {
ProviderType StorageType `json:"provider"`
HomePath string `json:"home_path"`
CompressAlg compress.CompressionType `json:"compress_alg,omitempty"`
FileExtention string `json:"file_extention,omitempty"`
Params map[string]string `json:"params"`
}
type SaveObjectProto ¶ added in v0.0.7
type SaveObjectProto struct {
Mx mfs.PMutex `json:"-"`
MxStor mfs.PMutex `json:"-"`
Rv int64 `json:"_rv"`
StorRv int64 `json:"_stor_rv"`
}
func (*SaveObjectProto) DataLock ¶ added in v0.0.7
func (sp *SaveObjectProto) DataLock(ctx context.Context) bool
func (*SaveObjectProto) DataRLock ¶ added in v0.0.7
func (sp *SaveObjectProto) DataRLock(ctx context.Context) bool
func (*SaveObjectProto) DataRUnlock ¶ added in v0.0.7
func (sp *SaveObjectProto) DataRUnlock()
func (*SaveObjectProto) DataUnlock ¶ added in v0.0.7
func (sp *SaveObjectProto) DataUnlock()
func (*SaveObjectProto) RvGetLast ¶ added in v0.0.7
func (sp *SaveObjectProto) RvGetLast() int64
func (*SaveObjectProto) RvGetStor ¶ added in v0.0.7
func (sp *SaveObjectProto) RvGetStor() int64
func (*SaveObjectProto) RvSetStor ¶ added in v0.0.7
func (sp *SaveObjectProto) RvSetStor(rv int64)
func (*SaveObjectProto) StorLock ¶ added in v0.0.7
func (sp *SaveObjectProto) StorLock(ctx context.Context) bool
func (*SaveObjectProto) StorUnlock ¶ added in v0.0.7
func (sp *SaveObjectProto) StorUnlock()
type SaveProto ¶ added in v0.0.8
type SaveProto struct {
SaveObjectProto
RVG *mft.G `json:"_rvg,omitempty"`
SaveToStorageValue Storage `json:"-"`
SaveToFileNameValue string `json:"-"`
SaveToContextValue func() (context.Context, context.CancelFunc) `json:"-"`
SaveToContextDuration time.Duration `json:"-"`
}
func (*SaveProto) SaveToContext ¶ added in v0.0.8
func (sp *SaveProto) SaveToContext() (context.Context, context.CancelFunc)
func (*SaveProto) SaveToFileName ¶ added in v0.0.8
func (*SaveProto) SaveToStorage ¶ added in v0.0.8
func (*SaveProto) SetNextPartRv ¶ added in v0.0.8
func (sp *SaveProto) SetNextPartRv()
type Storable ¶ added in v0.0.4
type Storable interface {
// StorLock - Lock object for storage
StorLock(ctx context.Context) bool
// StorUnlock - Unlock object for storage
StorUnlock()
// DataRLock - Lock object for read
DataRLock(ctx context.Context) bool
// DataRUnlock - Unlock object for read
DataRUnlock()
// DataLock - Lock object
DataLock(ctx context.Context) bool
// DataUnlock - Unlock object
DataUnlock()
// RvGetLast - get last object version
RvGetLast() int64
// RvGetLast - get last stored version
RvGetStor() int64
// RvSetStor - set last stored version
RvSetStor(rv int64)
// ToBytes - Object to bytes for save
ToBytes() (data []byte, err *mft.Error)
// FromBytes - Object from bytes for load
FromBytes(data []byte) (err *mft.Error)
}
type StorableSaveReady ¶ added in v0.0.8
type Storage ¶
type Storage interface {
// Exists name in storage
Exists(ctx context.Context, name string) (ok bool, err *mft.Error)
// Get data from storage
Get(ctx context.Context, name string) (body []byte, err *mft.Error)
// Save write data into storage
Save(ctx context.Context, name string, body []byte) *mft.Error
// Delete delete data from storage
Delete(ctx context.Context, name string) *mft.Error
// Rename rename file from oldName to newName
Rename(ctx context.Context, oldName string, newName string) *mft.Error
// MkDirIfNotExists make directory
MkDirIfNotExists(ctx context.Context, name string) *mft.Error
}
Storage - Save data into storage
type StorageType ¶ added in v0.0.4
type StorageType string
StorageType - type of storage
const ( // StorageMAPType - storage map type StorageMAPType StorageType = "map" // StorageFileType - storage file type (folder := homePath + folder) StorageFileType StorageType = "file" // StorageFileDoubleSaveType - storage file type with double (folder := homePath + folder) StorageFileDoubleSaveType StorageType = "file_dbl_save" // StorageFileDoubleSaveType - storage file type with double (folder := homePath + folder) StorageFileDoubleSaveTypeGZip StorageType = "file_dbl_save_gzip" )
type ZipSaveSorage ¶
type ZipSaveSorage struct {
// contains filtered or unexported fields
}
DoubleSaveSorage - storage that saves to Map (memory)
func CreateZipSaveSorage ¶
func CreateZipSaveSorage(storage Storage, compressor *compress.Generator, alghoritm compress.CompressionType, fileExtention string) *ZipSaveSorage
CreateDoubleSaveSorage - creates double_save_storage storange
func (*ZipSaveSorage) MkDirIfNotExists ¶
MkDirIfNotExists make directory
func (*ZipSaveSorage) Path ¶
func (s *ZipSaveSorage) Path(name string) string