Skip to content

Commit

Permalink
Merge 7071bd7 into 08e15f2
Browse files Browse the repository at this point in the history
  • Loading branch information
Han-MeiM committed Apr 25, 2021
2 parents 08e15f2 + 7071bd7 commit ecafd0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,27 @@ Agollo - Go Client for Apollo
方便Golang接入配置中心框架 [Apollo](https://github.com/ctripcorp/apollo) 所开发的Golang版本客户端。

# Features

* 支持多 IP、AppID、namespace
* 实时同步配置
* 灰度配置
* 延迟加载(运行时)namespace
* 客户端,配置文件容灾
* 自定义日志,缓存组件
* 支持配置访问秘钥

# Usage

## 快速入门

### 导入 agollo

```
go get -u github.com/zouyx/agollo/v4@latest
```

### 启动 agollo

```
package main
Expand All @@ -41,50 +44,53 @@ import (
"github.com/zouyx/agollo/v4/env/config"
)
func main(){
c := &config.AppConfig{
func main() {
c := &config.AppConfig{
AppID: "testApplication_yang",
Cluster: "dev",
IP: "http://106.54.227.205:8080",
NamespaceName: "dubbo",
IsBackupConfig: true,
Secret: "6ce3ff7e96a24335a9634fe9abca6d51",
}
agollo.SetLogger(&DefaultLogger{})
client,err:=agollo.StartWithConfig(func() (*config.AppConfig, error) {
client, err := agollo.StartWithConfig(func() (*config.AppConfig, error) {
return c, nil
})
fmt.Println("初始化Apollo配置成功")
//Use your apollo key to test
cache := client.GetConfigCache(c.NamespaceName)
value,_ := client.Get("key")
fmt.Println(value)
fmt.Println("初始化Apollo配置成功")
//Use your apollo key to test
cache := client.GetConfigCache(c.NamespaceName)
value, _ := client.Get("key")
fmt.Println(value)
}
```


## 更多用法

***使用Demo***[agollo_demo](https://github.com/zouyx/agollo_demo)

***其他语言***[agollo-agent](https://github.com/zouyx/agollo-agent.git) 做本地agent接入,如:PHP

欢迎查阅 [Wiki](https://github.com/zouyx/agollo/wiki) 或者 [godoc](http://godoc.org/github.com/zouyx/agollo) 获取更多有用的信息

如果你觉得该工具还不错或者有问题,一定要让我知道,可以发邮件或者[留言](https://github.com/zouyx/agollo/issues)

# User

* [使用者名单](https://github.com/zouyx/agollo/issues/20)

# Contribution
* Source Code: https://github.com/zouyx/agollo/
* Issue Tracker: https://github.com/zouyx/agollo/issues


* Source Code: https://github.com/zouyx/agollo/
* Issue Tracker: https://github.com/zouyx/agollo/issues

# License

The project is licensed under the [Apache 2 license](https://github.com/zouyx/agollo/blob/master/LICENSE).

# Reference

Apollo : https://github.com/ctripcorp/apollo
8 changes: 4 additions & 4 deletions protocol/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Request(requestURL string, connectionConfig *env.ConnectConfig, callBack *C
}
req, err := http.NewRequest("GET", requestURL, nil)
if req == nil || err != nil {
log.Error("Generate connect Apollo request Fail,url:%s,Error:%s", requestURL, err)
log.Errorf("Generate connect Apollo request Fail,url:%s,Error:%s", requestURL, err)
// if error then sleep
return nil, errors.New("generate connect Apollo request fail")
}
Expand All @@ -124,7 +124,7 @@ func Request(requestURL string, connectionConfig *env.ConnectConfig, callBack *C
}

if res == nil || err != nil {
log.Error("Connect Apollo Server Fail,url:%s,Error:%s", requestURL, err)
log.Errorf("Connect Apollo Server Fail,url:%s,Error:%s", requestURL, err)
// if error then sleep
time.Sleep(onErrorRetryInterval)
continue
Expand All @@ -135,7 +135,7 @@ func Request(requestURL string, connectionConfig *env.ConnectConfig, callBack *C
case http.StatusOK:
responseBody, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Error("Connect Apollo Server Fail,url:%s,Error:", requestURL, err)
log.Errorf("Connect Apollo Server Fail,url:%s,Error:", requestURL, err)
// if error then sleep
time.Sleep(onErrorRetryInterval)
continue
Expand All @@ -152,7 +152,7 @@ func Request(requestURL string, connectionConfig *env.ConnectConfig, callBack *C
}
return nil, nil
default:
log.Error("Connect Apollo Server Fail,url:%s,StatusCode:%s", requestURL, res.StatusCode)
log.Errorf("Connect Apollo Server Fail,url:%s,StatusCode:%s", requestURL, res.StatusCode)
// if error then sleep
time.Sleep(onErrorRetryInterval)
continue
Expand Down

0 comments on commit ecafd0e

Please sign in to comment.