- Multiple namespace support
- Fail tolerant
- Zero dependency
- Realtime change notification
- API to get contents of namespace
go 1.11 or later
go get -u github.com/philchia/agollo/v4
import "github.com/philchia/agollo/v4"
for namespaces with the format of properties, you need to specific the full name
agollo.Start(&agollo.Conf{
AppID: "your app id",
Cluster: "default",
NameSpaceNames: []string{"application.properties"},
MetaAddr: "your apollo meta addr",
})
apollo := agollo.New(&agollo.Conf{
AppID: "your app id",
Cluster: "default",
NameSpaceNames: []string{"application.properties"},
MetaAddr: "your apollo meta addr",
})
apollo.Start()
agollo.OnUpdate(func(event *ChangeEvent) {
// do your business logic to handle config update
})
// get values in the application.properties default namespace
val := agollo.GetString(Key)
// or indicate a namespace
other := agollo.GetString(key, agollo.WithNamespace("other namespace"))
to get namespace of with a format of properties, you need to specific the full name of the namespace, e.g. namespace.properties in both options and configs
namespaceContent := agollo.GetContent(agollo.WithNamespace("application.properties"))
allKyes := agollo.GetAllKeys(namespace)
agollo.SubscribeToNamespaces("newNamespace1", "newNamespace2")
agollo is released under MIT license