Documentation ¶
Overview ¶
Package globwatch implements a filesystem watcher that supports recursive watching using an extended glob pattern syntax.
The glob pattern syntax is descibed in github.com/halimath/globwatch/pattern.
The watcher is implemented based on a directory polling which periodically uses fs.WalkDir to walk a directory and check each file for changes. The watcher does not rely on kernel support like inotify or kqueue. The decision to work around these kernel features was made to support a large number of files and directories to watch. Especially with kqueue on MacOS you can quickly hit the open files limit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { // The event's type Type EventType // The full path of the file relative to the watched root Path string }
Event models a single event reported by a Watcher for a single file.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher implements glob watching. Events for changed files will be reported via C. Any error that occured during change detection will be reported vi Errors. Make sure you consume both channels or you will block change detection otherwise.
func New ¶
New creates a new watcher. The watcher will use fsys to access the files and directories. It will use fsys as the root to watch. pat defines the pattern relative to fsys' root. interval defines how often to check for changes. A created watcher will not start watching for changes unless Start or StartContext is called.
func (*Watcher) Close ¶
func (w *Watcher) Close()
Close closes w. The change detection goroutine will be shutdown gracefully and both w.C and w.Errors will be closed before Close returns.
func (*Watcher) ErrorsChan ¶
ErrorsChan returns a channel used to receive errors during watching.
Directories ¶
Path | Synopsis |
---|---|
Package main contains a useful demonstration application showing how to watch a directory for changes and print the results to stdout.
|
Package main contains a useful demonstration application showing how to watch a directory for changes and print the results to stdout. |
Package pattern implements a language for specifying glob patterns for path names starting at some root.
|
Package pattern implements a language for specifying glob patterns for path names starting at some root. |