Documentation
¶
Overview ¶
Package etcd defines EtcdClient interface, and use "go.etcd.io/etcd/client/v3" implements the interface.
Index ¶
- type ClientProperties
- type EtcdClient
- type EtcdConfiguration
- type EtcdV3Client
- func (c *EtcdV3Client) Close() error
- func (c *EtcdV3Client) Del(key string) (int64, error)
- func (c *EtcdV3Client) Get(key string) (string, error)
- func (c *EtcdV3Client) List(prefix string) ([]*KeyValue, error)
- func (c *EtcdV3Client) Put(key, value string) (string, error)
- func (c *EtcdV3Client) Watch(prefix string, startIndex int64, onEvent func(event *clientv3.Event))
- type KeyValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientProperties ¶
type ClientProperties struct {
Endpoints []string
UserName string
Password string
NeedAuthentication bool
ClientCert string
ClientKey string
CaCert string
}
ClientProperties properties for etcd
type EtcdClient ¶
type EtcdClient interface {
Get(key string) (string, error)
Put(key, value string) (string, error)
List(prefix string) ([]*KeyValue, error)
Del(key string) (int64, error)
Watch(prefix string, startIndex int64, onEvent func(event *clientv3.Event))
Close() error
}
func CreateEtcdClient ¶
func CreateEtcdClient(etcdConfiguration *EtcdConfiguration) EtcdClient
CreateEtcdClient according to yaml etcdConfiguration
type EtcdConfiguration ¶
type EtcdConfiguration struct {
APIVersion string `yaml:"apiVersion"`
Address string `yaml:"address"`
Username string `yaml:"username"`
Password string `yaml:"password"`
HTTPSEnable bool `yaml:"httpsEnable"`
ClientCert string `yaml:"clientCert"` // etcd cert file
ClientKey string `yaml:"clientKey"` // etcd cert-key file
CaCert string `yaml:"caCert"` // etcd ca file
}
EtcdConfiguration yaml etcd configuration entity
type EtcdV3Client ¶
EtcdV3Client implements EtcdClient interface.
func NewEtcdV3Client ¶
func NewEtcdV3Client(props *ClientProperties) (*EtcdV3Client, error)
NewEtcdV3Client create an *EtcdV3Client based on "go.etcd.io/etcd/client/v3"
func (*EtcdV3Client) Close ¶
func (c *EtcdV3Client) Close() error
func (*EtcdV3Client) Del ¶
func (c *EtcdV3Client) Del(key string) (int64, error)
Del delete the key which in etcd
func (*EtcdV3Client) Get ¶
func (c *EtcdV3Client) Get(key string) (string, error)
Get return the val corresponding to the key in etcd
func (*EtcdV3Client) List ¶
func (c *EtcdV3Client) List(prefix string) ([]*KeyValue, error)
List return a list key-val from etcd with prefix
Click to show internal directories.
Click to hide internal directories.