MCPcopy Create free account
hub / github.com/LockGit/gochat / InitConnectRpcClient

Method InitConnectRpcClient

task/rpc.go:82–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80}
81
82func (task *Task) InitConnectRpcClient() (err error) {
83 etcdConfigOption := &store.Config{
84 ClientTLS: nil,
85 TLS: nil,
86 ConnectionTimeout: time.Duration(config.Conf.Common.CommonEtcd.ConnectionTimeout) * time.Second,
87 Bucket: "",
88 PersistConnection: true,
89 Username: config.Conf.Common.CommonEtcd.UserName,
90 Password: config.Conf.Common.CommonEtcd.Password,
91 }
92 etcdConfig := config.Conf.Common.CommonEtcd
93 d, e := etcdV3.NewEtcdV3Discovery(
94 etcdConfig.BasePath,
95 etcdConfig.ServerPathConnect,
96 []string{etcdConfig.Host},
97 true,
98 etcdConfigOption,
99 )
100 if e != nil {
101 logrus.Fatalf("init task rpc etcd discovery client fail:%s", e.Error())
102 }
103 if len(d.GetServices()) <= 0 {
104 logrus.Infof("no etcd server find!")
105 }
106 // watch connect server change && update RpcConnectClientList
107 go task.watchServicesChange(d)
108 return
109}
110
111func (task *Task) watchServicesChange(d client.ServiceDiscovery) {
112 etcdConfig := config.Conf.Common.CommonEtcd

Callers 1

RunMethod · 0.95

Calls 1

watchServicesChangeMethod · 0.95

Tested by

no test coverage detected