Skip to content

Instantly share code, notes, and snippets.

@howeyc
Created October 25, 2013 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save howeyc/7156865 to your computer and use it in GitHub Desktop.
Save howeyc/7156865 to your computer and use it in GitHub Desktop.
Additional OptionsWatcher interface. Didn't actually attempt to use, just an idea.
type FileNotification interface {
IsCreate() bool
IsDelete() bool
IsModify() bool
IsRename() bool
Path() string // relative path to the file
}
type OptionWatcher interface {
Close() error
RemoveWatch(string) error
WatchPath(string, *Options) error
NextNotification() (FileNotification, error)
}
func NewOptionWatcher() (OptionWatcher, error) {
return NewWatcher()
}
func (w *Watcher) NextNotification() (fn FileNotification, err error) {
select {
case fn = <-w.internalEvent:
case err = <-w.Error:
}
return
}
@nathany
Copy link

nathany commented Oct 27, 2013

@howeyc One of my concerns is what happens when multiple watches have overlapping options, like a recursive watch on a subfolder with a different pattern match?

I'm wondering about the ability to watch multiple paths in a single watcher? Do we really need that. And if so, should some or all of the options be part of NewOptionWatcher() instead?

@nathany
Copy link

nathany commented Oct 27, 2013

What would the calling code for Next() look like?

Lots of iterator options http://ewencp.org/blog/golang-iterators/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment