File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ func main() {
22
22
var opss client.CallOption = func (o * client.CallOptions ) {
23
23
o .RequestTimeout = time .Second * 30
24
24
o .DialTimeout = time .Second * 30
25
+ o .Retries = 3
25
26
}
26
-
27
27
info , err := agent .RpcUserInfo (context .TODO (), & test_agent.ReqMsg {
28
28
UserName : "test user" ,
29
29
}, opss )
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "github.com/micro/go-micro/v2/config"
6
+ "github.com/micro/go-micro/v2/config/encoder/toml"
7
+ "github.com/micro/go-micro/v2/config/source"
8
+ "github.com/micro/go-micro/v2/config/source/etcd"
9
+ )
10
+
11
+ func main () {
12
+ conf , err := config .NewConfig ()
13
+ if err != nil {
14
+ panic (err )
15
+ }
16
+ t := toml .NewEncoder ()
17
+ sou := etcd .NewSource (
18
+ etcd .WithAddress ("192.168.1.86:2379" ),
19
+ etcd .WithPrefix ("/conf/" ),
20
+ etcd .StripPrefix (true ),
21
+ source .WithEncoder (t ),
22
+ )
23
+ if err = conf .Load (sou ); err != nil {
24
+ panic (err )
25
+ }
26
+ fmt .Println ("读取到配置" , string (conf .Get ("test" , "server" ).Bytes ()))
27
+ wath , err := conf .Watch ("test" , "server" )
28
+ if err != nil {
29
+ panic (err )
30
+ }
31
+ defer wath .Stop ()
32
+ for {
33
+ val , err := wath .Next ()
34
+ if err != nil {
35
+ panic (err )
36
+ }
37
+ fmt .Println (string (val .Bytes ()))
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments