Documentation ¶
Index ¶
- Constants
- type Client
- func (e *Client) Close() error
- func (e *Client) Delete(ctx context.Context, key string, withPrefixMatch bool) error
- func (e *Client) Get(ctx context.Context, key string) ([]byte, *mvccpb.KeyValue, error)
- func (e *Client) KeyWithRootPath(key string) string
- func (e *Client) List(ctx context.Context, key string) (*Node, error)
- func (e *Client) MultiGet(ctx context.Context, keys ...string) (map[string][]byte, error)
- func (e *Client) NewLease() clientv3.Lease
- func (e *Client) NewWatcher() clientv3.Watcher
- func (e *Client) PrefixGet(ctx context.Context, prefix string) (map[string][]byte, error)
- func (e *Client) Put(ctx context.Context, k string, val string, opts ...clientv3.OpOption) error
- func (e *Client) Txn(ctx context.Context) clientv3.Txn
- type DistributedLockGenerator
- type Node
- type URLsValue
Constants ¶
const (
// DefaultRootPath is the root path of the keys stored in etcd.
DefaultRootPath = "mysql/mysql-servers"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper of etcd client that support some simple method.
func NewClientFromCfg ¶
func NewClientFromCfg(endpoints []string, dialTimeout time.Duration, root string, clusterName, username, password string) (*Client, error)
NewClientFromCfg returns a customized wrapped etcd client.
func (*Client) Get ¶
Get returns a key/value matches the given key. returns the value, leaderID and error respectively
func (*Client) KeyWithRootPath ¶
KeyWithRootPath returns the full path of the key on etcd. when clientv3 api is used, all keys must be wrapped with this method for example, clientv3.Watch(ctx, client.KeyWithFullPath(key))
func (*Client) MultiGet ¶
MultiGet returns the map struct that contains key/value within the given keys.
func (*Client) NewWatcher ¶
NewWatcher creates a new watcher
func (*Client) PrefixGet ¶
PrefixGet returns the map struct that contains key/value with same prefix.
type DistributedLockGenerator ¶
type DistributedLockGenerator struct {
// contains filtered or unexported fields
}
DistributedLockGenerator implements LockGenerator interface
func NewDistributedLockGenerator ¶
func NewDistributedLockGenerator(client *Client, lockPrefix string, lockTTL int) DistributedLockGenerator
NewDistributedLockGenerator creates DistributedLockGenerator
type URLsValue ¶
URLsValue is an alias of URLs.
func NewURLsValue ¶
NewURLsValue returns a URLsValue from a string of URL list(separated by comma). e.g. http://192.168.0.2:2380, http://192.168.0.3:2380
func (*URLsValue) HostString ¶
HostString returns a string of 'host:port' list separated by comma.
func (*URLsValue) StringSlice ¶
StringSlice returns a slice of string with formatted URL.