Skip to content

Commit

Permalink
Finish v4.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyx committed Jul 30, 2023
2 parents f1bf7df + 3a95fe8 commit 914cd4f
Show file tree
Hide file tree
Showing 18 changed files with 445 additions and 164 deletions.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package agollo
import (
"container/list"
"errors"

"github.com/apolloconfig/agollo/v4/agcache"
"github.com/apolloconfig/agollo/v4/agcache/memory"
"github.com/apolloconfig/agollo/v4/cluster/roundrobin"
Expand Down Expand Up @@ -239,7 +240,7 @@ func (c *internalClient) getConfigValue(key string) interface{} {

value, err := cache.Get(key)
if err != nil {
log.Errorf("get config value fail!key:%s,err:%s", key, err)
log.Errorf("get config value fail! key:%s, error:%v", key, err)
return utils.Empty
}

Expand Down
2 changes: 1 addition & 1 deletion component/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func SyncServerIPListSuccessCallBack(responseBody []byte, callback http.CallBack
err = json2.Unmarshal(responseBody, &tmpServerInfo)

if err != nil {
log.Errorf("Unmarshal json Fail,Error: %s", err)
log.Errorf("Unmarshal json Fail, error: %v", err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion component/remote/abs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a *AbsApolloConfig) SyncWithNamespace(namespace string, appConfigFunc func
if appConfig.SyncServerTimeout > 0 {
duration, err := time.ParseDuration(strconv.Itoa(appConfig.SyncServerTimeout) + "s")
if err != nil {
log.Errorf("parse sync server timeout %s fail, error:%v", err)
log.Errorf("parse sync server timeout %s fail, error:%v", appConfig.SyncServerTimeout, err)
return nil
}
c.Timeout = duration
Expand Down
4 changes: 2 additions & 2 deletions component/remote/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func toApolloConfig(resBody []byte) ([]*config.Notification, error) {
err := json.Unmarshal(resBody, &remoteConfig)

if err != nil {
log.Errorf("Unmarshal Msg Fail,Error: %v", err)
log.Errorf("Unmarshal Msg Fail, error: %v", err)
return nil, err
}
return remoteConfig, nil
Expand Down Expand Up @@ -182,7 +182,7 @@ func createApolloConfigWithJSON(b []byte, callback http.CallBack) (o interface{}
}
m, err := parser.Parse(content)
if err != nil {
log.Debugf("GetContent fail ! error: %v", err)
log.Debugf("GetContent fail! error: %v", err)
}

if len(m) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion component/remote/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func processJSONFiles(b []byte, callback http.CallBack) (o interface{}, err erro
}
m, err := parser.Parse(content)
if err != nil {
log.Debugf("GetContent fail ! error: %v", err)
log.Debugf("GetContent fail! error: %v", err)
}

if len(m) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion component/serverlist/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func SyncServerIPListSuccessCallBack(responseBody []byte, callback http.CallBack
err = json.Unmarshal(responseBody, &tmpServerInfo)

if err != nil {
log.Error("Unmarshal json Fail,Error: %v", err)
log.Errorf("Unmarshal json Fail, error: %v", err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion env/config/json/json_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (t *ConfigFile) Write(content interface{}, configPath string) error {
}
file, e := os.Create(configPath)
if e != nil {
log.Errorf("writeConfigFile fail,error: %v", e)
log.Errorf("writeConfigFile fail, error: %v", e)
return e
}
defer file.Close()
Expand Down
4 changes: 2 additions & 2 deletions env/file/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (fileHandler *FileHandler) createDir(configPath string) error {
if !configFileDirMap[configPath] {
err := os.MkdirAll(configPath, os.ModePerm)
if err != nil && !os.IsExist(err) {
log.Errorf("Create backup dir:%s fail,error:&s", configPath, err)
log.Errorf("Create backup dir:%s fail, error:%v", configPath, err)
return err
}
configFileDirMap[configPath] = true
Expand Down Expand Up @@ -106,7 +106,7 @@ func (fileHandler *FileHandler) LoadConfigFile(configDir string, appID string, n
})

if c == nil || e != nil {
log.Errorf("loadConfigFile fail,error:", e)
log.Errorf("loadConfigFile fail, error:%v", e)
return nil, e
}

Expand Down
2 changes: 1 addition & 1 deletion env/file/json/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (fileHandler *rawFileHandler) WriteConfigFile(config *config.ApolloConfig,

err = writeWithRaw(config, configPath)
if err != nil {
log.Errorf("writeWithRaw fail! ", err)
log.Errorf("writeWithRaw fail! error:%v", err)
}
return jsonFileConfig.Write(config, fileHandler.GetConfigFile(configPath, config.AppID, config.NamespaceName))
}
Expand Down
16 changes: 8 additions & 8 deletions env/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Info struct {
nextTryConnTime int64
}

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

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

//SetDownNode 设置失效节点
// SetDownNode 设置失效节点
func SetDownNode(configService string, serverHost string) {
serverLock.Lock()
defer serverLock.Unlock()
Expand All @@ -99,15 +99,15 @@ func SetDownNode(configService string, serverHost string) {

for k, server := range s.serverMap {
// if some node has down then select next node
if strings.Index(k, serverHost) > -1 {
if strings.Contains(k, serverHost) {
server.IsDown = true
}
}
}

//IsConnectDirectly is connect by ip directly
//false : yes
//true : no
// IsConnectDirectly is connect by ip directly
// false : yes
// true : no
func IsConnectDirectly(configIp string) bool {
serverLock.Lock()
defer serverLock.Unlock()
Expand All @@ -122,7 +122,7 @@ func IsConnectDirectly(configIp string) bool {
return false
}

//SetNextTryConnTime if this connect is fail will set this time
// SetNextTryConnTime if this connect is fail will set this time
func SetNextTryConnTime(configIp string, nextPeriod int64) {
serverLock.Lock()
defer serverLock.Unlock()
Expand Down
8 changes: 3 additions & 5 deletions extension/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ import (

"github.com/apolloconfig/agollo/v4/env/config"

"github.com/apolloconfig/agollo/v4/env/file"
. "github.com/tevid/gohamcrest"
)

type TestFileHandler struct {
}

//WriteConfigFile 写入配置文件
// WriteConfigFile 写入配置文件
func (r *TestFileHandler) WriteConfigFile(config *config.ApolloConfig, configPath string) error {
return nil
}

//GetConfigFile 获得配置文件路径
// GetConfigFile 获得配置文件路径
func (r *TestFileHandler) GetConfigFile(configDir string, appID string, namespace string) string {
return ""
}
Expand All @@ -48,6 +47,5 @@ func TestSetFileHandler(t *testing.T) {

fileHandler := GetFileHandler()

b := fileHandler.(file.FileHandler)
Assert(t, b, NotNilVal())
Assert(t, fileHandler, NotNilVal())
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/apolloconfig/agollo/v4

require (
github.com/spf13/viper v1.7.1
github.com/spf13/viper v1.8.1
github.com/tevid/gohamcrest v1.1.1
)

Expand Down
Loading

0 comments on commit 914cd4f

Please sign in to comment.