| 123456789101112131415161718192021222324252627282930 |
- package etcd
- import (
- "github.com/coreos/etcd/clientv3"
- "time"
- )
- type EtcdClient struct {
- c *clientv3.Client
- }
- func Connect(servers []string, username, password string, timeout time.Duration) (*EtcdClient, error) {
- etcd := &EtcdClient{}
- var err error
- conf := clientv3.Config{
- Endpoints:servers,
- DialTimeout: timeout,
- }
- if len(username) > 0 {
- conf.Username = username
- conf.Password = password
- }
- etcd.c, err = clientv3.New(conf)
- return etcd, err
- }
- func (self *EtcdClient) Put() {
- self.c.Put()
- }
|