https://github.com/scriptllh/go-disconf-client
go disconf 客户端
https://github.com/scriptllh/go-disconf-client
Last synced: 11 months ago
JSON representation
go disconf 客户端
- Host: GitHub
- URL: https://github.com/scriptllh/go-disconf-client
- Owner: scriptllh
- License: apache-2.0
- Created: 2018-02-06T09:38:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-08T08:18:33.000Z (over 7 years ago)
- Last Synced: 2025-04-24T13:40:42.179Z (about 1 year ago)
- Language: Go
- Size: 1.08 MB
- Stars: 24
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#### go disconf 客户端
***
1.使用说明
* 传一个结构体的指针,支持数据类型(支持int、int64、string、bool、float32、float64)
* 支持两种tag:conf、auto
* 支持默认参数(WithRetryTimes(3)、WithRetrySleepSeconds(5)、WithDownloadDir(./disconf/download/)、WithIgnore)
* tag conf 是属性文件中的名称,如果加了auto:"true"表示该属性在disconf服务端更新之后,客户端会自动加载
* example
```
type Conf struct {
UserName string `conf:"mysql.username"`
Password string `conf:"mysql.password" auto:"true"`
A int `conf:"a" auto:"true"`
TextGBK string `conf:"textGBK" auto:"true"`
}
```
```
conf := &Conf{UserName: "root", Password: "dsdhjhj"}
if err := NewConf(
"127.0.0.1",
"disconf_demo",
"222",
"dev",
true,
false,
conf,
WithDownloadDir("./disconf/download/")); err != nil {
t.Fatalf("new conf [err:%v]", err)
}
for {
fmt.Println("a", conf.Password)
time.Sleep(5 * time.Second)
}
```
***
###### 整体架构

***
###### 特性
1. 支持自定义配置文件下载路径
2. 支持配置文件和配置项
3. 支持可配置的只加载本地配置
4. 不需要重启更改配置文件或配置项
5. 应用程序无感知