通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
[TOC] ## 实例 **配置定义** ``` etcdctl get /configs/remote_config.json { "addr" : "127.0.0.1:1080", "aes_key" : "01B345B7A9ABC00F0123456789ABCDAF", "https" : false, "secret" : "", "private_key_path" : "", "cert_file_path" : "" } ``` 新建 etcd client ``` cfg := client.Config{ Endpoints: []string{"http://127.0.0.1:2379"}, Transport: client.DefaultTransport, HeaderTimeoutPerRequest: time.Second, } ``` 配置获取 ``` resp, err = kapi.Get(context.Background(), "/path/to/your/config", nil) if err != nil { log.Fatal(err) } else { log.Printf("Get is done. Metadata is %q\n", resp) log.Printf("%q key has %q value\n", resp.Node.Key, resp.Node.Value) } ``` 配置更新订阅 ``` kapi := client.NewKeysAPI(c) w := kapi.Watcher("/path/to/your/config", nil) go func() { for { resp, err := w.Next(context.Background()) log.Println(resp, err) log.Println("new values is ", resp.Node.Value) } }() ```