Documentation ¶
Index ¶
- Variables
- func DeleteIfExists(ctx context.Context, st Storage, name string) (err *mft.Error)
- func GenerateError(key int, a ...interface{}) *mft.Error
- func GenerateErrorE(key int, err error, a ...interface{}) *mft.Error
- type CreateFileSorageParams
- 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 Storage
- 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",
}
Errors codes and description
var StorageFileDoubleSaveType = "file_dbl_save"
StorageFileDoubleSaveType - storage file type with double (folder := homePath + folder)
var StorageFileDoubleSaveTypeGZip = "file_dbl_save_gzip"
StorageFileDoubleSaveType - storage file type with double (folder := homePath + folder)
var StorageFileType = "file"
StorageFileType - storage file type (folder := homePath + folder)
var StorageMAPType = "map"
StorageMAPType - storage map type
Functions ¶
func DeleteIfExists ¶
DeleteIfExists delete file if exists
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 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 // Rename make directory MkDirIfNotExists(ctx context.Context, name string) *mft.Error }
Storage - Save data into storage
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 string, 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