-
Notifications
You must be signed in to change notification settings - Fork 53
/
main.go
33 lines (28 loc) · 665 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"github.com/micro-in-cn/XConf/pkg/client/source"
"github.com/micro/go-micro/v2/config"
"github.com/micro/go-micro/v2/util/log"
)
func main() {
c, err := config.NewConfig(
config.WithSource(
source.NewSource("app", "dev", "test", source.WithURL("http://xconf.mogutou.xyz"))))
if err != nil {
panic(err)
}
log.Info("read: ", string(c.Get().Bytes()))
// Watch 返回前 micro config 会调用 Read 读一次配置
w, err := c.Watch()
if err != nil {
panic(err)
}
for {
// 会比较 value,内容不变不会返回
v, err := w.Next()
if err != nil {
panic(err)
}
log.Info("watch: ", string(v.Bytes()))
}
}