Skip to content

Commit 914cd4f

Browse files
committed
Finish v4.3.1
2 parents f1bf7df + 3a95fe8 commit 914cd4f

File tree

18 files changed

+445
-164
lines changed

18 files changed

+445
-164
lines changed

client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package agollo
2020
import (
2121
"container/list"
2222
"errors"
23+
2324
"github.com/apolloconfig/agollo/v4/agcache"
2425
"github.com/apolloconfig/agollo/v4/agcache/memory"
2526
"github.com/apolloconfig/agollo/v4/cluster/roundrobin"
@@ -239,7 +240,7 @@ func (c *internalClient) getConfigValue(key string) interface{} {
239240

240241
value, err := cache.Get(key)
241242
if err != nil {
242-
log.Errorf("get config value fail!key:%s,err:%s", key, err)
243+
log.Errorf("get config value fail! key:%s, error:%v", key, err)
243244
return utils.Empty
244245
}
245246

component/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func SyncServerIPListSuccessCallBack(responseBody []byte, callback http.CallBack
146146
err = json2.Unmarshal(responseBody, &tmpServerInfo)
147147

148148
if err != nil {
149-
log.Errorf("Unmarshal json Fail,Error: %s", err)
149+
log.Errorf("Unmarshal json Fail, error: %v", err)
150150
return
151151
}
152152

component/remote/abs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (a *AbsApolloConfig) SyncWithNamespace(namespace string, appConfigFunc func
4949
if appConfig.SyncServerTimeout > 0 {
5050
duration, err := time.ParseDuration(strconv.Itoa(appConfig.SyncServerTimeout) + "s")
5151
if err != nil {
52-
log.Errorf("parse sync server timeout %s fail, error:%v", err)
52+
log.Errorf("parse sync server timeout %s fail, error:%v", appConfig.SyncServerTimeout, err)
5353
return nil
5454
}
5555
c.Timeout = duration

component/remote/async.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func toApolloConfig(resBody []byte) ([]*config.Notification, error) {
138138
err := json.Unmarshal(resBody, &remoteConfig)
139139

140140
if err != nil {
141-
log.Errorf("Unmarshal Msg Fail,Error: %v", err)
141+
log.Errorf("Unmarshal Msg Fail, error: %v", err)
142142
return nil, err
143143
}
144144
return remoteConfig, nil
@@ -182,7 +182,7 @@ func createApolloConfigWithJSON(b []byte, callback http.CallBack) (o interface{}
182182
}
183183
m, err := parser.Parse(content)
184184
if err != nil {
185-
log.Debugf("GetContent fail ! error: %v", err)
185+
log.Debugf("GetContent fail! error: %v", err)
186186
}
187187

188188
if len(m) > 0 {

component/remote/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func processJSONFiles(b []byte, callback http.CallBack) (o interface{}, err erro
9090
}
9191
m, err := parser.Parse(content)
9292
if err != nil {
93-
log.Debugf("GetContent fail ! error: %v", err)
93+
log.Debugf("GetContent fail! error: %v", err)
9494
}
9595

9696
if len(m) > 0 {

component/serverlist/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func SyncServerIPListSuccessCallBack(responseBody []byte, callback http.CallBack
109109
err = json.Unmarshal(responseBody, &tmpServerInfo)
110110

111111
if err != nil {
112-
log.Error("Unmarshal json Fail,Error: %v", err)
112+
log.Errorf("Unmarshal json Fail, error: %v", err)
113113
return
114114
}
115115

env/config/json/json_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (t *ConfigFile) Write(content interface{}, configPath string) error {
5555
}
5656
file, e := os.Create(configPath)
5757
if e != nil {
58-
log.Errorf("writeConfigFile fail,error: %v", e)
58+
log.Errorf("writeConfigFile fail, error: %v", e)
5959
return e
6060
}
6161
defer file.Close()

env/file/json/json.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (fileHandler *FileHandler) createDir(configPath string) error {
6161
if !configFileDirMap[configPath] {
6262
err := os.MkdirAll(configPath, os.ModePerm)
6363
if err != nil && !os.IsExist(err) {
64-
log.Errorf("Create backup dir:%s fail,error:&s", configPath, err)
64+
log.Errorf("Create backup dir:%s fail, error:%v", configPath, err)
6565
return err
6666
}
6767
configFileDirMap[configPath] = true
@@ -106,7 +106,7 @@ func (fileHandler *FileHandler) LoadConfigFile(configDir string, appID string, n
106106
})
107107

108108
if c == nil || e != nil {
109-
log.Errorf("loadConfigFile fail,error:", e)
109+
log.Errorf("loadConfigFile fail, error:%v", e)
110110
return nil, e
111111
}
112112

env/file/json/raw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (fileHandler *rawFileHandler) WriteConfigFile(config *config.ApolloConfig,
6868

6969
err = writeWithRaw(config, configPath)
7070
if err != nil {
71-
log.Errorf("writeWithRaw fail! ", err)
71+
log.Errorf("writeWithRaw fail! error:%v", err)
7272
}
7373
return jsonFileConfig.Write(config, fileHandler.GetConfigFile(configPath, config.AppID, config.NamespaceName))
7474
}

env/server/server.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Info struct {
4343
nextTryConnTime int64
4444
}
4545

46-
//GetServersLen 获取服务器数组
46+
// GetServersLen 获取服务器数组
4747
func GetServers(configIp string) map[string]*config.ServerInfo {
4848
serverLock.Lock()
4949
defer serverLock.Unlock()
@@ -53,7 +53,7 @@ func GetServers(configIp string) map[string]*config.ServerInfo {
5353
return ipMap[configIp].serverMap
5454
}
5555

56-
//GetServersLen 获取服务器数组长度
56+
// GetServersLen 获取服务器数组长度
5757
func GetServersLen(configIp string) int {
5858
serverLock.Lock()
5959
defer serverLock.Unlock()
@@ -72,7 +72,7 @@ func SetServers(configIp string, serverMap map[string]*config.ServerInfo) {
7272
}
7373
}
7474

75-
//SetDownNode 设置失效节点
75+
// SetDownNode 设置失效节点
7676
func SetDownNode(configService string, serverHost string) {
7777
serverLock.Lock()
7878
defer serverLock.Unlock()
@@ -99,15 +99,15 @@ func SetDownNode(configService string, serverHost string) {
9999

100100
for k, server := range s.serverMap {
101101
// if some node has down then select next node
102-
if strings.Index(k, serverHost) > -1 {
102+
if strings.Contains(k, serverHost) {
103103
server.IsDown = true
104104
}
105105
}
106106
}
107107

108-
//IsConnectDirectly is connect by ip directly
109-
//false : yes
110-
//true : no
108+
// IsConnectDirectly is connect by ip directly
109+
// false : yes
110+
// true : no
111111
func IsConnectDirectly(configIp string) bool {
112112
serverLock.Lock()
113113
defer serverLock.Unlock()
@@ -122,7 +122,7 @@ func IsConnectDirectly(configIp string) bool {
122122
return false
123123
}
124124

125-
//SetNextTryConnTime if this connect is fail will set this time
125+
// SetNextTryConnTime if this connect is fail will set this time
126126
func SetNextTryConnTime(configIp string, nextPeriod int64) {
127127
serverLock.Lock()
128128
defer serverLock.Unlock()

0 commit comments

Comments
 (0)