Documentation ¶
Index ¶
- Variables
- func Cleanup(fname string) error
- func Events(fname string) <-chan fsnotify.Event
- func IsDeletePending(_ *os.File) (bool, error)
- func RemoveWatch(fname string) error
- func RemoveWatchCreate(fname string) error
- func Watch(fname string) error
- func WatchCreate(fname string) error
- type FileChanges
- type FileWatcher
- type InotifyFileWatcher
- type InotifyTracker
- type PollingFileWatcher
- type PollingFileWatcherOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultPollingFileWatcherOptions = PollingFileWatcherOptions{ MinPollFrequency: 250 * time.Millisecond, MaxPollFrequency: 250 * time.Millisecond, }
DefaultPollingFileWatcherOptions holds default values for PollingFileWatcherOptions.
Functions ¶
func Events ¶
func Events(fname string) <-chan fsnotify.Event
Events returns a channel to which FileEvents corresponding to the input filename will be sent. This channel will be closed when removeWatch is called on this filename.
func RemoveWatch ¶
RemoveWatch signals the run goroutine to remove the watch for the input filename
func RemoveWatchCreate ¶
RemoveWatch create signals the run goroutine to remove the watch for the input filename
func WatchCreate ¶
Watch create signals the run goroutine to begin watching the input filename if call the WatchCreate function, don't call the Cleanup, call the RemoveWatchCreate
Types ¶
type FileChanges ¶
type FileChanges struct { Modified chan bool // Channel to get notified of modifications Truncated chan bool // Channel to get notified of truncations Deleted chan bool // Channel to get notified of deletions/renames }
func NewFileChanges ¶
func NewFileChanges() *FileChanges
func (*FileChanges) NotifyDeleted ¶
func (fc *FileChanges) NotifyDeleted()
func (*FileChanges) NotifyModified ¶
func (fc *FileChanges) NotifyModified()
func (*FileChanges) NotifyTruncated ¶
func (fc *FileChanges) NotifyTruncated()
type FileWatcher ¶
type FileWatcher interface { // BlockUntilExists blocks until the file comes into existence. BlockUntilExists(*tomb.Tomb) error // ChangeEvents reports on changes to a file, be it modification, // deletion, renames or truncations. Returned FileChanges group of // channels will be closed, thus become unusable, after a deletion // or truncation event. // In order to properly report truncations, ChangeEvents requires // the caller to pass their current offset in the file. ChangeEvents(*tomb.Tomb, int64) (*FileChanges, error) SetFile(f *os.File) }
FileWatcher monitors file-level events.
type InotifyFileWatcher ¶
InotifyFileWatcher uses inotify to monitor file changes.
func NewInotifyFileWatcher ¶
func NewInotifyFileWatcher(filename string) *InotifyFileWatcher
func (*InotifyFileWatcher) BlockUntilExists ¶
func (fw *InotifyFileWatcher) BlockUntilExists(t *tomb.Tomb) error
func (*InotifyFileWatcher) ChangeEvents ¶
func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error)
func (*InotifyFileWatcher) SetFile ¶
func (fw *InotifyFileWatcher) SetFile(_ *os.File)
type InotifyTracker ¶
type InotifyTracker struct {
// contains filtered or unexported fields
}
type PollingFileWatcher ¶
type PollingFileWatcher struct { File *os.File Filename string Size int64 Options PollingFileWatcherOptions }
PollingFileWatcher polls the file for changes.
func NewPollingFileWatcher ¶
func NewPollingFileWatcher(filename string, opts PollingFileWatcherOptions) (*PollingFileWatcher, error)
func (*PollingFileWatcher) BlockUntilExists ¶
func (fw *PollingFileWatcher) BlockUntilExists(t *tomb.Tomb) error
func (*PollingFileWatcher) ChangeEvents ¶
func (fw *PollingFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error)
func (*PollingFileWatcher) SetFile ¶
func (fw *PollingFileWatcher) SetFile(f *os.File)
type PollingFileWatcherOptions ¶
type PollingFileWatcherOptions struct {
// MinPollFrequency and MaxPollFrequency specify how frequently a
// PollingFileWatcher should poll the file.
//
// PollingFileWatcher starts polling at MinPollFrequency, and will
// exponentially increase the polling frequency up to MaxPollFrequency if no
// new entries are found. The polling frequency is reset to MinPollFrequency
// whenever a new log entry is found or if the polled file changes.
MinPollFrequency, MaxPollFrequency time.Duration
}
PollingFileWatcherOptions customizes a PollingFileWatcher.