Skip to content

Instantly share code, notes, and snippets.

@yangzh
Created August 19, 2014 17:13
Show Gist options
  • Save yangzh/eb1e4e5809c5fa13ad3d to your computer and use it in GitHub Desktop.
Save yangzh/eb1e4e5809c5fa13ad3d to your computer and use it in GitHub Desktop.
watchChan := make(chan *etcd.Response)
stopChan := make(chan bool)
go onConfigChange(watchChan, stopChan)
c.Watch("/test", 0, false, watchChan, stopChan)
func onConfigChange(watchChan chan *etcd.Response, stopChan chan bool) {
for {
select {
case response, ok := <-watchChan:
if !ok {
log.Fatalf("Watch chan closed?")
continue
}
// Handle config change...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment