Created
October 25, 2013 15:50
-
-
Save howeyc/7156865 to your computer and use it in GitHub Desktop.
Additional OptionsWatcher interface. Didn't actually attempt to use, just an idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
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
@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?