Documentation
¶
Index ¶
- Variables
- type DirEntry
- type FileService
- type IOEntry
- type IOVector
- type LocalFS
- func (l *LocalFS) Delete(ctx context.Context, filePath string) error
- func (l *LocalFS) List(ctx context.Context, dirPath string) (ret []DirEntry, err error)
- func (l *LocalFS) Mutate(ctx context.Context, vector IOVector) error
- func (l *LocalFS) Read(ctx context.Context, vector *IOVector) error
- func (l *LocalFS) Write(ctx context.Context, vector IOVector) error
- type MemoryFS
- func (m *MemoryFS) Delete(ctx context.Context, filePath string) error
- func (m *MemoryFS) List(ctx context.Context, dirPath string) (entries []DirEntry, err error)
- func (m *MemoryFS) Read(ctx context.Context, vector *IOVector) error
- func (m *MemoryFS) Write(ctx context.Context, vector IOVector) error
- type MutableFileService
- type S3Config
- type S3FS
- type S3FSMinio
- func (m *S3FSMinio) Delete(ctx context.Context, filePath string) error
- func (m *S3FSMinio) List(ctx context.Context, dirPath string) (entries []DirEntry, err error)
- func (m *S3FSMinio) Read(ctx context.Context, vector *IOVector) error
- func (m *S3FSMinio) Write(ctx context.Context, vector IOVector) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type FileService ¶
type FileService interface {
// Write writes a new file
// returns ErrFileExisted if file already existed
// returns ErrSizeNotMatch if provided size does not match data
// entries in vector should be written atomically. if write failed, following reads must not succeed.
Write(ctx context.Context, vector IOVector) error
// Read reads a file to fill IOEntries
// returns ErrFileNotFound if requested file not found
// returns ErrUnexpectedEOF if less data is read than requested size
// returns ErrEmptyRange if no data at specified offset and size
Read(ctx context.Context, vector *IOVector) error
// List lists sub-entries in a dir
List(ctx context.Context, dirPath string) ([]DirEntry, error)
// Delete deletes a file
// returns ErrFileNotFound if requested file not found
Delete(ctx context.Context, filePath string) error
}
FileService is a write-once file system
type IOEntry ¶
type IOEntry struct {
// offset in file, [0, len(file) - 1]
Offset int
// number of bytes to be read of written, [1, len(file)]
Size int
// raw content
// when reading, if len(Data) < Size, a new Size-lengthed byte slice will be allocated
Data []byte
// when reading, if Writer is not nil, write data to it instead of setting Data field
WriterForRead io.Writer
// when reading, if ReadCloser is not nil, set an io.ReadCloser instead of setting Data field
ReadCloserForRead *io.ReadCloser
// when writing, if Reader is not nil, read data from it instead of reading Data field
ReaderForWrite io.Reader
}
type LocalFS ¶
LocalFS is a FileService implementation backed by local file system
func NewLocalFS ¶
type MemoryFS ¶
MemoryFS is an in-memory FileService implementation
func NewMemoryFS ¶
type MutableFileService ¶
type MutableFileService interface {
FileService
// Mutate mutates file contents
Mutate(ctx context.Context, vector IOVector) error
}
MutableFileService is an extension interface to FileService that allow mutation
type S3FS ¶
type S3FS struct {
// contains filtered or unexported fields
}
S3FS is a FileService implementation backed by S3
Click to show internal directories.
Click to hide internal directories.