Documentation ¶
Overview ¶
Package storage provides storage abstraction for LevelDB.
Index ¶
- Variables
- type File
- type FileStorage
- func (d *FileStorage) Close() error
- func (d *FileStorage) GetFile(number uint64, t FileType) File
- func (d *FileStorage) GetFiles(t FileType) (r []File)
- func (d *FileStorage) GetManifest() (f File, err error)
- func (d *FileStorage) Lock() (l Locker, err error)
- func (d *FileStorage) Print(str string)
- func (d *FileStorage) SetManifest(f File) (err error)
- type FileType
- type Locker
- type MemStorage
- type Reader
- type Storage
- type Syncer
- type Writer
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type File ¶
type File interface { // Open file for read. // Should return os.ErrNotExist if the file does not exist. Open() (r Reader, err error) // Create file for write. Truncate if file already exist. Create() (w Writer, err error) // Rename to given number and type. Rename(number uint64, t FileType) error // Return true if the file is exist. Exist() bool // Return file type. Type() FileType // Return file number Num() uint64 // Return size of the file. Size() (size uint64, err error) // Remove file. Remove() error }
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage provide implementation of file-system backed storage.
func OpenFile ¶
func OpenFile(dbpath string) (d *FileStorage, err error)
OpenFile creates new initialized FileStorage for given path. This will also hold file lock; thus any subsequent attempt to open same file path will fail.
func (*FileStorage) Close ¶
func (d *FileStorage) Close() error
Close closes the storage and release the lock.
func (*FileStorage) GetFile ¶
func (d *FileStorage) GetFile(number uint64, t FileType) File
GetFile get file with given number and type.
func (*FileStorage) GetFiles ¶
func (d *FileStorage) GetFiles(t FileType) (r []File)
GetFiles get all files that match given file types; multiple file type may OR'ed together.
func (*FileStorage) GetManifest ¶
func (d *FileStorage) GetManifest() (f File, err error)
GetManifest get manifest file.
func (*FileStorage) Lock ¶
func (d *FileStorage) Lock() (l Locker, err error)
Lock lock the storage.
func (*FileStorage) Print ¶
func (d *FileStorage) Print(str string)
Print write given str to the log file.
func (*FileStorage) SetManifest ¶
func (d *FileStorage) SetManifest(f File) (err error)
SetManifest set manifest to given file.
type FileType ¶
type FileType uint32
const ( TypeManifest FileType = 1 << iota TypeJournal TypeTable TypeAll = TypeManifest | TypeJournal | TypeTable )
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
MemStorage provide implementation of memory backed storage.
func (*MemStorage) GetFile ¶
func (m *MemStorage) GetFile(num uint64, t FileType) File
GetFile get file with given number and type.
func (*MemStorage) GetFiles ¶
func (m *MemStorage) GetFiles(t FileType) (r []File)
GetFiles get all files that match given file types; multiple file type may OR'ed together.
func (*MemStorage) GetManifest ¶
func (m *MemStorage) GetManifest() (f File, err error)
GetManifest get manifest file.
func (*MemStorage) SetManifest ¶
func (m *MemStorage) SetManifest(f File) error
SetManifest set manifest to given file.
type Storage ¶
type Storage interface { // Lock the storage, so any subsequent attempt to lock the same storage // will fail. Lock() (l Locker, err error) // Print a string, for logging. Print(str string) // Get file with given number and type. GetFile(number uint64, t FileType) File // Get all files that match given file types; multiple file type // may OR'ed together. GetFiles(t FileType) []File // Get manifest file. // Should return os.ErrNotExist if there's no current manifest file. GetManifest() (f File, err error) // Set manifest to given file. SetManifest(f File) error }