自动更新API节点配置

This commit is contained in:
GoEdgeLab
2021-02-24 09:00:12 +08:00
parent e9016a2d5d
commit 16d661a236
3 changed files with 115 additions and 0 deletions

View File

@@ -342,6 +342,12 @@ func (this *RPCClient) APIContext(apiNodeId int64) context.Context {
return ctx
}
// 修改配置
func (this *RPCClient) UpdateConfig(config *configs.APIConfig) error {
this.apiConfig = config
return this.init()
}
// 初始化
func (this *RPCClient) init() error {
// 重新连接
@@ -369,7 +375,9 @@ func (this *RPCClient) init() error {
if len(conns) == 0 {
return errors.New("[RPC]no available endpoints")
}
this.locker.Lock()
this.conns = conns
this.locker.Unlock()
return nil
}