Documentation ¶
Overview ¶
This is a generalized filesystem watcher with ideas taken from the https://github.com/6degreeshealth/autotest package
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filewatcher ¶
type Filewatcher struct { FileChanged chan string FolderChanged chan string Error chan error Closed chan struct{} // contains filtered or unexported fields }
func New ¶
func New(options Options, pollDuration time.Duration) (*Filewatcher, error)
New creates a debounced file watcher. It will watch for changes to the filesystem every `pollDuration` duration and notify of changes after no change has been seen in that file or folder in 2x the `pollDuration`. For example, if the pollDuration is set to 1 second, the debounceDuration will automatically be set to 2 seconds. This would be the timeline then for an example file: (0 seconds) poll for changes: none found (0.3 seconds) folder1/file1 updated (1 second) poll for changes: 1 folder1/file1 and 1 folder1 change found
debounce timer for folder1 created for 2 seconds due to change debounce timer for folder1/file1 created for 2 seconds due to change
(1.1 second) folder1/file2 updated (2 seconds) poll for changes - 1 folder1/file2 and 1 folder1 change found
debounce timer for folder1 reset to 2 seconds due to new change to folder1 debounce timer for folder1/file2 created for 2 seconds due to change
(3 seconds) poll for changes - no new changes found
debounce timer finishes for folder1/file1. FileChanged channel publishes the filename
(4 seconds) poll for changes - no new changes found
debounce timer finishes for folder1/file2. FileChanged channel publishes the filename debounce timer finishes for folder1. FileChanged channel publishes the folder name
func (*Filewatcher) Close ¶
func (w *Filewatcher) Close()
func (*Filewatcher) Start ¶
func (w *Filewatcher) Start()
func (*Filewatcher) WatchFolders ¶
func (w *Filewatcher) WatchFolders() []string
WatchFolders returns the current list of folders being watched by gobounce