forked from philchia/agollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
agollo.go
61 lines (49 loc) · 1.53 KB
/
agollo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package agollo
var (
defaultClient *Client
)
// Start agollo
func Start() error {
return StartWithConfFile(defaultConfName)
}
// StartWithConfFile run agollo with conf file
func StartWithConfFile(name string) error {
conf, err := NewConf(name)
if err != nil {
return err
}
return StartWithConf(conf)
}
// StartWithConf run agollo with Conf
func StartWithConf(conf *Conf) error {
defaultClient = NewClient(conf)
return defaultClient.Start()
}
// Stop sync config
func Stop() error {
return defaultClient.Stop()
}
// WatchUpdate get all updates
func WatchUpdate() <-chan *ChangeEvent {
return defaultClient.WatchUpdate()
}
// SubscribeToNamespaces fetch namespace config to local and subscribe to updates
func SubscribeToNamespaces(namespaces ...string) error {
return defaultClient.SubscribeToNamespaces(namespaces...)
}
// GetStringValueWithNameSpace get value from given namespace
func GetStringValueWithNameSpace(namespace, key, defaultValue string) string {
return defaultClient.GetStringValueWithNameSpace(namespace, key, defaultValue)
}
// GetStringValue from default namespace
func GetStringValue(key, defaultValue string) string {
return GetStringValueWithNameSpace(defaultNamespace, key, defaultValue)
}
// GetNameSpaceContent get contents of namespace
func GetNameSpaceContent(namespace, defaultValue string) string {
return defaultClient.GetNameSpaceContent(namespace, defaultValue)
}
// GetAllKeys return all config keys in given namespace
func GetAllKeys(namespace string) []string {
return defaultClient.GetAllKeys(namespace)
}