-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
Currently Watch accepts a stop channel and returns an event channel. I'd like to make a simpler API that emulates bufio.Scanner. This should wrap the existing implementation to preserve binary compatibility, and to not break users who might need to select on multiple watchers.
Below is an example of what the new API would look like:
Initialize a watcher, and clean it up when we're done with it:
watcher, err := client.NewWatcher(unmarshaller)
if err != nil {
// handle error
}
defer watcher.Close()
Iterate through events, and handle errors:
for watcher.Listen() {
if err := watcher.ParseError(); err != nil {
log.Println("Malformed event: ", err)
}
event := watcher.Event()
// process event
}
if err := watcher.Error(); err != nil {
// handle error
}