etcd golang watch

前端之家收集整理的这篇文章主要介绍了etcd golang watch前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
package main import ( "log" "github.com/coreos/go-etcd/etcd" ) func main() { client := etcd.NewClient( []string{ "http://127.0.0.1:2379",},) for { resp,err := client.Get("config",false,false) if err != nil { log.Fatal(err) } log.Printf("Current creds: %s: %s\n",resp.Node.Key,resp.Node.Value) receiver := make(chan *etcd.Response) go client.Watch("/config",receiver,nil) r := <-receiver log.Printf("Got updated creds: %s: %s\n",r.Node.Key,r.Node.Value) } }

猜你在找的Go相关文章