Skip to content

scriptllh/go-disconf-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
		}

整体架构

avatar


特性
1.  支持自定义配置文件下载路径

2.  支持配置文件和配置项

3.  支持可配置的只加载本地配置

4.  不需要重启更改配置文件或配置项

5.  应用程序无感知

About

go disconf 客户端

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages