go-disconf-client disconf客户端 go-disconf-client

scriptllh2018-03-15 19:51:39 • 1771 次点击    
这是一个分享于 2018-03-15 19:51:39 的项目,其中的信息可能已经有所发展或是发生改变。

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

go disconf 客户端Read More

Latest commit to the master branch on 10-8-2018
Download as zip
授权协议:
开发语言:
go 查看源码»
1771 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传