README
¶
goo-etcd
set/get
var cfg = goo_etcd.Config{
User: "test",
Password: "123456",
Endpoints: []string{"localhost:23791", "localhost:23792", "localhost:23793"},
}
func init() {
goo_etcd.Init(cfg)
}
func main() {
key := "/test/proj.com/grpc-user/v100"
val := "hnatao"
goo_etcd.Set(key, val, 0)
goo_log.Debug(goo_etcd.Get(key))
}
GetMap
var cfg = goo_etcd.Config{
User: "test",
Password: "123456",
Endpoints: []string{"localhost:23791", "localhost:23792", "localhost:23793"},
}
func init() {
goo_etcd.Init(cfg)
}
func main() {
key := "/test/proj.com/grpc-user"
key1 := "/test/proj.com/grpc-user/v100"
val1 := "hnatao-1"
key2 := "/test/proj.com/grpc-user/v101"
val2 := "hnatao-2"
goo_etcd.Set(key1, val1, 0)
goo_etcd.Set(key2, val2, 0)
goo_log.Debug(goo_etcd.GetMap(key))
}
GetArray
var cfg = goo_etcd.Config{
User: "test",
Password: "123456",
Endpoints: []string{"localhost:23791", "localhost:23792", "localhost:23793"},
}
func init() {
goo_etcd.Init(cfg)
}
func main() {
key := "/test/proj.com/grpc-user"
key1 := "/test/proj.com/grpc-user/v100"
val1 := "hnatao-1"
key2 := "/test/proj.com/grpc-user/v101"
val2 := "hnatao-2"
goo_etcd.Set(key1, val1, 0)
goo_etcd.Set(key2, val2, 0)
goo_log.Debug(goo_etcd.GetArray(key))
}
SetWithKeepAlive
var cfg = goo_etcd.Config{
User: "test",
Password: "123456",
Endpoints: []string{"localhost:23791", "localhost:23792", "localhost:23793"},
}
func init() {
goo_etcd.Init(cfg)
}
func main() {
key := "/test/proj.com/grpc-user/v100"
val := "hnatao-1"
goo_etcd.SetWithKeepAlive(key, val, 15)
goo_utils.AsyncFunc(func() {
for {
select {
case <-goo_context.Cancel().Done():
return
default:
goo_log.Debug(goo_etcd.Get(key))
time.Sleep(time.Second)
}
}
})
<-goo_context.Timeout(20 * time.Second).Done()
}
Documentation
¶
Index ¶
- func Del(key string) error
- func Get(key string) string
- func GetArray(key string) (data []string)
- func GetMap(key string) (data map[string]string)
- func Init(cfg Config)
- func Set(key, val string, ttl int64) (err error)
- func SetWithKeepAlive(key, val string, ttl int64) (err error)
- func Watch(key string, fn func(arr []string))
- type Client
- func (cli *Client) Del(key string) (err error)
- func (cli *Client) Get(key string) string
- func (cli *Client) GetArray(key string) (data []string)
- func (cli *Client) GetMap(key string) (data map[string]string)
- func (cli *Client) Set(key, val string, ttl int64) (err error)
- func (cli *Client) SetWithKeepAlive(key, val string, ttl int64) (err error)
- func (cli *Client) Watch(key string, fn func([]string))
- type Config
- type TLS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetWithKeepAlive ¶
Types ¶
type Client ¶
func (*Client) SetWithKeepAlive ¶
Click to show internal directories.
Click to hide internal directories.