Skip to content

Commit

Permalink
[fix]: add some log for naming selectInstances (#681)
Browse files Browse the repository at this point in the history
* add log for naming selectInstances

* add some error logs for config

* fix up
  • Loading branch information
robynron authored Nov 10, 2023
1 parent 79bf755 commit 03026b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 23 additions & 2 deletions clients/config_client/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ func (client *ConfigClient) getConfigInner(param *vo.ConfigParam) (content strin
logger.Warnf("read config from cache success, dataId=%s, group=%s, namespaceId=%s", param.DataId, param.Group, clientConfig.NamespaceId)
return cacheContent, nil
}
if response != nil && response.Response != nil && !response.IsSuccess() {
return response.Content, errors.New(response.GetMessage())
}
param.EncryptedDataKey = response.EncryptedDataKey
param.Content = response.Content
return response.Content, nil
Expand Down Expand Up @@ -281,8 +284,11 @@ func (client *ConfigClient) PublishConfig(param vo.ConfigParam) (published bool,
request.AdditionMap["encryptedDataKey"] = param.EncryptedDataKey
rpcClient := client.configProxy.getRpcClient(client)
response, err := client.configProxy.requestProxy(rpcClient, request, constant.DEFAULT_TIMEOUT_MILLS)
if err != nil {
return false, err
}
if response != nil {
return response.IsSuccess(), err
return client.buildResponse(response)
}
return false, err
}
Expand All @@ -301,8 +307,11 @@ func (client *ConfigClient) DeleteConfig(param vo.ConfigParam) (deleted bool, er
request := rpc_request.NewConfigRemoveRequest(param.Group, param.DataId, clientConfig.NamespaceId)
rpcClient := client.configProxy.getRpcClient(client)
response, err := client.configProxy.requestProxy(rpcClient, request, constant.DEFAULT_TIMEOUT_MILLS)
if err != nil {
return false, err
}
if response != nil {
return response.IsSuccess(), err
return client.buildResponse(response)
}
return false, err
}
Expand Down Expand Up @@ -509,6 +518,11 @@ func (client *ConfigClient) refreshContentAndCheck(cacheData cacheData, notify b
cacheData.group, cacheData.tenant)
return
}
if configQueryResponse != nil && configQueryResponse.Response != nil && !configQueryResponse.IsSuccess() {
logger.Errorf("refresh cached config from server error:%v, dataId=%s, group=%s", configQueryResponse.GetMessage(),
cacheData.dataId, cacheData.group)
return
}
cacheData.content = configQueryResponse.Content
cacheData.contentType = configQueryResponse.ContentType
cacheData.encryptedDataKey = configQueryResponse.EncryptedDataKey
Expand Down Expand Up @@ -551,3 +565,10 @@ func (client *ConfigClient) asyncNotifyListenConfig() {
client.listenExecute <- struct{}{}
}()
}

func (client *ConfigClient) buildResponse(response rpc_response.IResponse) (bool, error) {
if response.IsSuccess() {
return response.IsSuccess(), nil
}
return false, errors.New(response.GetMessage())
}
1 change: 1 addition & 0 deletions clients/naming_client/naming_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (sc *NamingClient) selectInstances(service model.Service, healthy bool) ([]
}
hosts := service.Hosts
var result []model.Instance
logger.Infof("select instances with options: [healthy:<%s>], with service:<%s>", healthy, util.GetGroupName(service.Name, service.GroupName))
for _, host := range hosts {
if host.Healthy == healthy && host.Enable && host.Weight > 0 {
result = append(result, host)
Expand Down

0 comments on commit 03026b7

Please sign in to comment.