Documentation ¶
Index ¶
- type FS
- func (fs *FS) Create(dir string, name string, size uint64) (types.WritableFile, error)
- func (fs *FS) Delete(dir string, name string) error
- func (fs *FS) ListDir(dir string) ([]string, error)
- func (fs *FS) OpenReader(dir string, name string) (types.ReadableFile, error)
- func (fs *FS) OpenWriter(dir string, name string) (types.WritableFile, error)
- type File
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS struct { }
FS implements the wal.VFS interface using GO's built in OS Filesystem (and a few helpers).
TODO if we changed the interface to be Dir centric we could cache the open dir handle and save some time opening it on each Create in order to fsync.
func (*FS) Create ¶
Create creates a new file with the given name. If a file with the same name already exists an error is returned. If a non-zero size is given, implementations should make a best effort to pre-allocate the file to be that size. The dir must already exist and be writable to the current process.
func (*FS) Delete ¶
Delete indicates the file is no longer required. Typically it should be deleted from the underlying system to free disk space.
func (*FS) ListDir ¶
ListDir returns a list of all files in the specified dir in lexicographical order. If the dir doesn't exist, it must return an error. Empty array with nil error is assumed to mean that the directory exists and was readable, but contains no files.
func (*FS) OpenReader ¶
OpenReader opens an existing file in read-only mode. If the file doesn't exist or permission is denied, an error is returned, otherwise no checks are made about the well-formedness of the file, it may be empty, the wrong size or corrupt in arbitrary ways.
func (*FS) OpenWriter ¶
OpenWriter opens a file in read-write mode. If the file doesn't exist or permission is denied, an error is returned, otherwise no checks are made about the well-formedness of the file, it may be empty, the wrong size or corrupt in arbitrary ways.
type File ¶
File wraps an os.File and implements types.WritableFile. It ensures that the first time Sync is called on the file, that the parent directory is also Fsynced to ensure a crash won't cause the FS to forget the file is there.
Postponing this allows us to ensure that we do the minimum necessary fsyncs but still ensure all required fsyncs are done by the time we acknowledge committed data in the new file.