Versions in this module Expand all Collapse all v0 v0.1.1 Dec 16, 2020 v0.1.0 Nov 6, 2020 Changes in this version + const MaxFileChunkDataSize + const MaxFileChunkNum + const MaxSequentialFileDataSize + const ReadMode + const SequentialFileChunkMetadataSize + const SequentialFileMetadataSize + const WriteMode + var DataOutOfChunkError = errors.New("not enough space to write chunk data") + var DataOutOfFileError = errors.New("not enough space to write data to file") + var DuplicateFileNameError = errors.New("duplicate file name error") + var EntryTooLargeError = errors.New("entry is too large") + var InvalidChunkIdError = errors.New("invalid chunk id") + var InvalidOperationError = errors.New("invalid operation") + var InvalidPartitionIdError = errors.New("invalid partition id") + var InvalidRetValue = errors.New("invalid ret value") + var PartitionNumLimitError = errors.New("partition num limit error") + var S = NewFileStorage() + type EntrySequenceFile struct + func NewEntrySequenceFile(path string, mode int) (*EntrySequenceFile, error) + func (f *EntrySequenceFile) Close() error + func (f *EntrySequenceFile) Delete() error + func (f *EntrySequenceFile) ReadEntry() ([]byte, error) + func (f *EntrySequenceFile) WriteEntry(entry []byte) error + type File struct + ContentType string + CreatedAt int64 + Id string + Name string + Partitions Partitions + Size uint32 + func (f *File) OpenStream() io.Reader + type FileChunk struct + func (c *FileChunk) Validate() bool + type FileDataReader struct + func (r *FileDataReader) Read(p []byte) (n int, err error) + type FileStorage struct + func NewFileStorage() *FileStorage + func (fs *FileStorage) DeleteFile(id string) bool + func (fs *FileStorage) Destroy() + func (fs *FileStorage) GetAllFiles() []*File + func (fs *FileStorage) GetFile(id string) (f *File, ok bool) + func (fs *FileStorage) SaveFile(fileName string, contentType string, reader io.Reader) (*File, error) + type LRUPartitionCache struct + func (c *LRUPartitionCache) Destroy() + func (c *LRUPartitionCache) GetChunk(id PartitionId, onFail func() FileChunk) FileChunk + type PartitionCache interface + Destroy func() + GetChunk func(id PartitionId, onFail func() FileChunk) FileChunk + type PartitionId uint32 + type Partitions []PartitionId + type SequentialFile struct + func NewSequentialFile(path string, chunkSize uint16, chunkCap uint16) (s *SequentialFile, err error) + func (s *SequentialFile) AppendChunk(data []byte) (chunkId uint16, err error) + func (s *SequentialFile) Close() (err error) + func (s *SequentialFile) Delete() error + func (s *SequentialFile) DeleteChunk(chunkId uint16) error + func (s *SequentialFile) IsWritable() bool + func (s *SequentialFile) ReadChunk(chunkId uint16) (chunk *FileChunk, err error)