Created
August 19, 2014 17:13
-
-
Save yangzh/eb1e4e5809c5fa13ad3d to your computer and use it in GitHub Desktop.
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
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