Documentation ¶
Overview ¶
Package storage provides storage abstraction for LevelDB.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FileDescOk ¶ added in v1.4.0
FileDescOk returns true if fd is a valid file descriptor.
Types ¶
type ErrCorrupted ¶ added in v1.4.0
ErrCorrupted is the type that wraps errors that indicate corruption of a file. Package storage has its own type instead of using errors.ErrCorrupted to prevent circular import.
func (*ErrCorrupted) Error ¶ added in v1.4.0
func (e *ErrCorrupted) Error() string
type FileDesc ¶ added in v1.4.0
FileDesc is a file descriptor.
type FileType ¶
type FileType int
const ( TypeManifest FileType = 1 << iota TypeJournal TypeTable TypeTemp TypeAll = TypeManifest | TypeJournal | TypeTable | TypeTemp )
type Storage ¶
type Storage interface { // Lock locks the storage. Any subsequent attempt to call Lock will fail // until the last lock released. // After use the caller should call the Release method. Lock() (Lock, error) // Log logs a string. This is used for logging. // An implementation may write to a file, stdout or simply do nothing. Log(str string) // SetMeta sets to point to the given fd, which then can be acquired using // GetMeta method. // SetMeta should be implemented in such way that changes should happened // atomically. SetMeta(fd FileDesc) error // GetManifest returns a manifest file. // Returns os.ErrNotExist if meta doesn't point to any fd, or point to fd // that doesn't exist. GetMeta() (FileDesc, error) // List returns fds that match the given file types. // The file types may be OR'ed together. List(ft FileType) ([]FileDesc, error) // Open opens file with the given fd read-only. // Returns os.ErrNotExist error if the file does not exist. // Returns ErrClosed if the underlying storage is closed. Open(fd FileDesc) (Reader, error) // Create creates file with the given fd, truncate if already exist and // opens write-only. // Returns ErrClosed if the underlying storage is closed. Create(fd FileDesc) (Writer, error) // Remove removes file with the given fd. // Returns ErrClosed if the underlying storage is closed. Remove(fd FileDesc) error // Rename renames file from oldfd to newfd. // Returns ErrClosed if the underlying storage is closed. Rename(oldfd, newfd FileDesc) error // Close closes the storage. // It is valid to call Close multiple times. Other methods should not be // called after the storage has been closed. Close() error }
Storage is the storage. A storage instance must be goroutine-safe.
func NewMemStorage ¶
func NewMemStorage() Storage
NewMemStorage returns a new memory-backed storage implementation.
type Syncer ¶
type Syncer interface { // Sync commits the current contents of the file to stable storage. Sync() error }
Syncer is the interface that wraps basic Sync method.
type Writer ¶
type Writer interface { io.WriteCloser Syncer }
Writer is the interface that groups the basic Write, Sync and Close methods.
Click to show internal directories.
Click to hide internal directories.