var POLL_DURATION time.Duration
func Cleanup(fname string) error
Cleanup removes the watch for the input filename if necessary.
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(fname string) error
RemoveWatch signals the run goroutine to remove the watch for the input filename
func RemoveWatchCreate(fname string) error
RemoveWatch create signals the run goroutine to remove the watch for the input filename
func Watch(fname string) error
Watch signals the run goroutine to begin watching the input filename
func WatchCreate(fname string) error
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
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() *FileChanges
func (fc *FileChanges) NotifyDeleted()
func (fc *FileChanges) NotifyModified()
func (fc *FileChanges) NotifyTruncated()
FileWatcher monitors file-level events.
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) }
InotifyFileWatcher uses inotify to monitor file changes.
type InotifyFileWatcher struct { Filename string Size int64 }
func NewInotifyFileWatcher(filename string) *InotifyFileWatcher
func (fw *InotifyFileWatcher) BlockUntilExists(t *tomb.Tomb) error
func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error)
type InotifyTracker struct {
// contains filtered or unexported fields
}
PollingFileWatcher polls the file for changes.
type PollingFileWatcher struct { Filename string Size int64 }
func NewPollingFileWatcher(filename string) *PollingFileWatcher
func (fw *PollingFileWatcher) BlockUntilExists(t *tomb.Tomb) error
func (fw *PollingFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error)