-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.go
55 lines (43 loc) · 1.58 KB
/
register.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
package rd
import (
"log"
clientV3 "go.etcd.io/etcd/client/v3"
"github.com/v8fg/rd/config"
"github.com/v8fg/rd/internal/registering"
)
var (
registerRegistry = registering.NewRegisterRegistry()
)
func init() {
}
// RegisterEtcd etcd register with some configurations.
// registry key: name or key, the name preferred.
func RegisterEtcd(config *config.RegisterConfig, client *clientV3.Client, etcdConfig *clientV3.Config) error {
return registerRegistry.Register(config, client, etcdConfig)
}
// RegisterInfo return the basic info about register: key and register addr.
func RegisterInfo() string {
return registerRegistry.Info()
}
// RegisterRun the registers have been registered.
func RegisterRun() []error {
return registerRegistry.Run()
}
// RegisterRunWithParam run the register have been registered and with the specified name or key.
func RegisterRunWithParam(nameOrKey string) []error {
return registerRegistry.RunWithParam(nameOrKey)
}
// RegisterClose close all the running registers.
func RegisterClose() []error {
return registerRegistry.Close()
}
// RegisterCloseWithParam close all the running registers with the specified key or name.
func RegisterCloseWithParam(nameOrKey string) []error {
return registerRegistry.CloseWithParam(nameOrKey)
}
// RegisterUpdateVal update the register val, shall not call, if no necessary.
// If you want call success, must set MutableVal=true when init the register.
func RegisterUpdateVal(nameOrKey, val string) error {
log.Printf("RegisterUpdateVal nameOrKey:%v, val:%v", nameOrKey, val)
return registerRegistry.UpdateVal(nameOrKey, val)
}