Categorygithub.com/livbarn/agollo
modulepackage
1.8.0
Repository: https://github.com/livbarn/agollo.git
Documentation: pkg.go.dev

# README

Agollo - Go Client for Apollo

golang Build Status Go Report Card codebeat badge Coverage Status License GoDoc GitHub release 996.icu

方便Golang接入配置中心框架 Apollo 所开发的Golang版本客户端。

其他语言 : 可使用 agollo-agent 做本地agent接入。

Installation

如果还没有安装Go开发环境,请参考以下文档Getting Started ,安装完成后,请执行以下命令:

gopm get github.com/cihub/seelog -v -g
gopm get github.com/coocood/freecache -v -g

或者

go get -u github.com/cihub/seelog
go get -u github.com/coocood/freecache

请注意: 最好使用Go 1.8进行开发

Features

  • 实时同步配置
  • 灰度配置
  • 客户端容灾
  • 配置文件容灾 (v1.6.0+)

Usage

  • 异步启动agollo

场景:启动程序不依赖加载Apollo的配置。

func main() {
	 go agollo.Start()
}
  • 同步启动agollo(v1.2.0+)

场景:启动程序依赖加载Apollo的配置。例:初始化程序基础配置。

func main() {
	 agollo.Start()
}
  • 启动agollo - 自定义logger控件(感谢 @Adol1111 提供)
func main() {
	 go agollo.StartWithLogger(loggerInterface)
}
  • 启动agollo - 自定义cache控件 (v1.7.0+)
func main() {
	 go agollo.StartWithCache(cacheInterface)
}
  • 监听变更事件(阻塞)
func main() {
	event := agollo.ListenChangeEvent()
	changeEvent := <-event
	bytes, _ := json.Marshal(changeEvent)
	fmt.Println("event:", string(bytes))
}
  • 获取Apollo的配置

    • String
    agollo.GetStringValue(Key,DefaultValue)
    
    • Int
    agollo.GetIntValue(Key,DefaultValue)
    
    • Float
    agollo.GetFloatValue(Key,DefaultValue)
    
    • Bool
    agollo.GetBoolValue(Key,DefaultValue)
    

 后续可支持更多类型

 欢迎查阅 Wiki 或者 godoc 获取更多有用的信息

 如果你觉得该工具还不错或者有问题,一定要让我知道,可以发邮件或者留言

User

Contribution

License

The project is licensed under the Apache 2 license.

Reference

Apollo : https://github.com/ctripcorp/apollo

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
init config by custom.
list config change event.
start apollo.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
本地模式.
No description provided by the author
服务器模式.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
config change event.
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

config change type.