Documentation ¶
Index ¶
- func SetEtcdCliByNamespace(cli *clientv3.Client, namespacePrefix string)
- type Client
- func (e *Client) Close() error
- func (e *Client) Create(ctx context.Context, key string, val string, opts []clientv3.OpOption) (int64, error)
- func (e *Client) Delete(ctx context.Context, key string, withPrefix bool) error
- func (e *Client) DoTxn(ctx context.Context, operations []*Operation) (int64, error)
- func (e *Client) Get(ctx context.Context, key string) (value []byte, revision int64, err error)
- func (e *Client) GetClient() *clientv3.Client
- func (e *Client) List(ctx context.Context, key string) (node *Node, revision int64, err error)
- func (e *Client) Update(ctx context.Context, key string, val string, ttl int64) error
- func (e *Client) UpdateOrCreate(ctx context.Context, key string, val string, ttl int64) error
- func (e *Client) Watch(ctx context.Context, prefix string, revision int64) clientv3.WatchChan
- type Node
- type OpType
- type Operation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetEtcdCliByNamespace ¶
SetEtcdCliByNamespace is used to add an etcd namespace prefix before etcd path.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapped etcd client that support some simple method
func NewClientFromCfg ¶
func NewClientFromCfg(endpoints []string, dialTimeout time.Duration, root string, security *tls.Config) (*Client, error)
NewClientFromCfg returns a wrapped etcd client
func (*Client) Create ¶
func (e *Client) Create(ctx context.Context, key string, val string, opts []clientv3.OpOption) (int64, error)
Create guarantees to set a key = value with some options(like ttl)
func (*Client) DoTxn ¶
DoTxn does some operation in one transaction. Note: should only have one opereration for one key, otherwise will get duplicate key error.
func (*Client) List ¶
List returns the trie struct that constructed by the key/value with same prefix
func (*Client) UpdateOrCreate ¶
UpdateOrCreate updates a key/value, if the key does not exist then create, or update
Click to show internal directories.
Click to hide internal directories.