etcd

package
v3.0.3+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a wrapped etcd client that support some simple method

func NewClient

func NewClient(cli *clientv3.Client, root string) *Client

NewClient returns a wrapped etcd client

func NewClientFromCfg

func NewClientFromCfg(endpoints []string, dialTimeout time.Duration, root string, security *tls.Config) (*Client, error)

NewClientFromCfg returns a wrapped etcd client

func (*Client) Close

func (e *Client) Close() error

Close shutdowns the connection to etcd

func (*Client) Create

func (e *Client) Create(ctx context.Context, key string, val string, opts []clientv3.OpOption) error

Create guarantees to set a key = value with some options(like ttl)

func (*Client) Delete

func (e *Client) Delete(ctx context.Context, key string, withPrefix bool) error

Delete deletes the key/values with matching prefix or key

func (*Client) Get

func (e *Client) Get(ctx context.Context, key string) (value []byte, revision int64, err error)

Get returns a key/value matchs the given key

func (*Client) List

func (e *Client) List(ctx context.Context, key string) (node *Node, revision int64, err error)

List returns the trie struct that constructed by the key/value with same prefix

func (*Client) Update

func (e *Client) Update(ctx context.Context, key string, val string, ttl int64) error

Update updates a key/value. set ttl 0 to disable the Lease ttl feature

func (*Client) UpdateOrCreate

func (e *Client) UpdateOrCreate(ctx context.Context, key string, val string, ttl int64) error

UpdateOrCreate updates a key/value, if the key does not exist then create, or update

func (*Client) Watch

func (e *Client) Watch(ctx context.Context, prefix string, revision int64) clientv3.WatchChan

Watch watchs the events of key with prefix.

type Node

type Node struct {
	Value  []byte
	Childs map[string]*Node
}

Node organizes the ectd query result as a Trie tree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL