自动同步API节点配置

This commit is contained in:
GoEdgeLab
2021-02-24 11:01:06 +08:00
parent e87d4b42ba
commit acc2df7fea
2 changed files with 105 additions and 0 deletions

View File

@@ -158,6 +158,12 @@ func (this *RPCClient) Close() {
}
}
// 修改配置
func (this *RPCClient) UpdateConfig(config *configs.APIConfig) error {
this.apiConfig = config
return this.init()
}
// 初始化
func (this *RPCClient) init() error {
// 重新连接
@@ -185,6 +191,8 @@ func (this *RPCClient) init() error {
if len(conns) == 0 {
return errors.New("[RPC]no available endpoints")
}
// 这里不需要加锁防止和pickConn()冲突
this.conns = conns
return nil
}