-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathagollo.go
56 lines (45 loc) · 1.4 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
package agollo
import (
"sync"
)
var (
once sync.Once
defaultClient Client
)
// Start agollo client with Conf, start will block until fetch all config to local
func Start(conf *Conf, opts ...ClientOption) error {
once.Do(func() { defaultClient = NewClient(conf, opts...) })
return defaultClient.Start()
}
// Stop sync config
func Stop() error {
return defaultClient.Stop()
}
// OnUpdate get all updates
func OnUpdate(handler func(*ChangeEvent)) {
defaultClient.OnUpdate(handler)
}
// SubscribeToNamespaces fetch namespace config to local and subscribe to updates
func SubscribeToNamespaces(namespaces ...string) error {
return defaultClient.SubscribeToNamespaces(namespaces...)
}
// GetString get value from given namespace
func GetString(key string, opts ...OpOption) string {
return defaultClient.GetString(key, opts...)
}
// GetNameSpaceContent get contents of namespace
func GetContent(opts ...OpOption) string {
return defaultClient.GetContent(opts...)
}
// GetPropertiesContent for properties namespace
func GetPropertiesContent(opts ...OpOption) string {
return defaultClient.GetPropertiesContent(opts...)
}
// GetAllKeys return all config keys in given namespace
func GetAllKeys(opts ...OpOption) []string {
return defaultClient.GetAllKeys(opts...)
}
// GetReleaseKey return release key for namespace
func GetReleaseKey(opts ...OpOption) string {
return defaultClient.GetReleaseKey(opts...)
}