()
| 80 | } |
| 81 | |
| 82 | func (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 | |
| 111 | func (task *Task) watchServicesChange(d client.ServiceDiscovery) { |
| 112 | etcdConfig := config.Conf.Common.CommonEtcd |
no test coverage detected