Documentation ¶
Index ¶
- type ContextRespectingIoFile
- func (f *ContextRespectingIoFile) Close(ctx context.Context) error
- func (f *ContextRespectingIoFile) Read(ctx context.Context, p []byte) (l int, err error)
- func (f *ContextRespectingIoFile) Seek(ctx context.Context, offset int64, whence int) (int64, error)
- func (f *ContextRespectingIoFile) Skip(ctx context.Context, n int64) error
- func (f *ContextRespectingIoFile) Tell(ctx context.Context) (int64, error)
- func (f *ContextRespectingIoFile) Write(ctx context.Context, b []byte) (int, error)
- type FileAdapter
- func (file *FileAdapter) ListEntries(ctx context.Context, dirurl *url.URL) ([]string, error)
- func (file *FileAdapter) OpenAppender(ctx context.Context, fileurl *url.URL) (rc filesystem.WriteCloser, err error)
- func (file *FileAdapter) OpenReader(ctx context.Context, fileurl *url.URL) (rc filesystem.ReadCloser, err error)
- func (file *FileAdapter) OpenWriter(ctx context.Context, fileurl *url.URL) (rc filesystem.WriteCloser, err error)
- func (file *FileAdapter) Remove(ctx context.Context, objurl *url.URL) error
- func (file *FileAdapter) WatchFile(ctx context.Context, fileurl *url.URL, notify filesystem.FileWatchFunc) (filesystem.CancelWatchFunc, chan error, error)
- type FileWatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextRespectingIoFile ¶
type ContextRespectingIoFile struct {
// contains filtered or unexported fields
}
ContextRespectingIoFile represents a regular file object from the OS, but with implementations of respecting deadlines and cancellations from contexts.
func NewContextRespectingIoFile ¶
func NewContextRespectingIoFile(actualFile *os.File) *ContextRespectingIoFile
NewContextRespectingIoFile wraps a regular os.File so we get a context respecting API on it.
func (*ContextRespectingIoFile) Close ¶
func (f *ContextRespectingIoFile) Close(ctx context.Context) error
Close() provides regular close semantics, but with support for cancelling waiting for closes to finish (which may be important due to caches) or providing deadlines for them.
func (*ContextRespectingIoFile) Read ¶
Read() provides regular read semantics, but with support for cancelling reads or providing deadlines for them.
func (*ContextRespectingIoFile) Seek ¶
func (f *ContextRespectingIoFile) Seek( ctx context.Context, offset int64, whence int) (int64, error)
Seek() sets the current position in the file to the absolute offset specified.
func (*ContextRespectingIoFile) Skip ¶
func (f *ContextRespectingIoFile) Skip(ctx context.Context, n int64) error
Skip() skips forward by the specified number of bytes without actually reading the data.
type FileAdapter ¶
type FileAdapter struct { }
File system adapter for local files. See http://github.com/childoftheuniverse/filesystem/ for details of the API and how to use it.
func (*FileAdapter) ListEntries ¶
ListEntries asynchronously reads the contents of a directory and returns the relative names of files and subdirectories in it. The actual enumeration will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.
func (*FileAdapter) OpenAppender ¶
func (file *FileAdapter) OpenAppender( ctx context.Context, fileurl *url.URL) (rc filesystem.WriteCloser, err error)
Asynchronously create a writer writing to the specified file, appending to the end of existent contents. The actual opening will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.
func (*FileAdapter) OpenReader ¶
func (file *FileAdapter) OpenReader( ctx context.Context, fileurl *url.URL) (rc filesystem.ReadCloser, err error)
Asynchronously create a reader reading from the specified file. The actual opening will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.
func (*FileAdapter) OpenWriter ¶
func (file *FileAdapter) OpenWriter( ctx context.Context, fileurl *url.URL) (rc filesystem.WriteCloser, err error)
Asynchronously create a writer writing to the specified file, overwriting all existent contents. The actual opening will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.
func (*FileAdapter) Remove ¶
Remove asynchronously deletes the object pointed to from the file system, without touching any entries below it (files, subdirectories). The actual deletion will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.
func (*FileAdapter) WatchFile ¶
func (file *FileAdapter) WatchFile(ctx context.Context, fileurl *url.URL, notify filesystem.FileWatchFunc) (filesystem.CancelWatchFunc, chan error, error)
Watch for changes affecting the file pointed to. Context is ignored since it probably wouldn't be meaningful in this context. The current state of the file will be notified at first as the initial change.
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatchers are used for holding all the accounting data necessary to keep track of changes to specific files in the file system. They follow the specified semantics of the filesystem API.
func NewFileWatcher ¶
func NewFileWatcher(ctx context.Context, path *url.URL, cb filesystem.FileWatchFunc) ( *FileWatcher, error)
NewFileWatcher creates a new FileWatcher watching for any changes in the specified file or, when pointed to a directory, any files inside of it. Changes will be reported using the callback. The initial version of the file is also reported as a change, allowing to use this for e.g. loading a configuration file in case of modifications.
func (*FileWatcher) ErrChan ¶
func (f *FileWatcher) ErrChan() chan error
Accessor method to get the error reporting channel.
func (*FileWatcher) Shutdown ¶
func (f *FileWatcher) Shutdown() error
Shutdown tells the system to stop watching for changes to the file(s) and shuts down the asynchronous change watching thread.