- var hosts = []string{"http://localhost:4001"}
- var client = etcd.NewClient(hosts)
- var es = NewEtcdServices(client)
- func TestSubscribe(t *testing.T) {
- stop := make(chan struct{})
- respchan, _ := es.Subscribe("redis")
- _, err := es.Register("redis", "redis1", "172.0.0.1", stop)
- if err != nil {
- t.Error(err)
- }
- resp := <- respchan
- if resp.Action != "set" {
- t.Fatal(resp.Action)
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/0807201614830.html
来源: http://www.codesnippet.cn/detail/0807201614830.html