goo_etcd

package
v1.1.126 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

README

KEY 命名规范

/命名空间/项目名/服务名/节点名

方法说明

  • Set 设置 key-value
  • SetWithPrevKV 设置 key-value 并且返回修改之前的 key-value
  • SetTTL 设置有有效期的 key-value
  • SetTTLWithPrevKV 设置有有效期的 key-value 并且返回修改之前的 key-value
  • Get 返回 response 信息
  • GetString 根据 key 前缀,返回 string-value
  • GetArray 根据 key 前缀,返回 array-value
  • GetMap 根据 key 前缀,返回 map-value
  • Del 删除 key 并且返回删除之前的 key-value
  • DelWithPrefix 根据 key 前缀删除, 并且返回删除之前的 key-value
  • RegisterService 注册一个服务,并保持活跃
  • Watch 根据 key 前缀观察,并返回 array-value

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Del

func Del(key string) (resp *clientv3.DeleteResponse, err error)

func DelWithPrefix added in v1.1.1

func DelWithPrefix(key string) (resp *clientv3.DeleteResponse, err error)

func Get

func Get(key string, opts ...clientv3.OpOption) (rsp *clientv3.GetResponse, err error)

func GetArray

func GetArray(key string) (data []string)

func GetMap

func GetMap(key string) (data map[string]string)

func GetString added in v1.1.1

func GetString(key string) string

func Init

func Init(conf Config)

func RegisterService added in v1.1.1

func RegisterService(key, val string) (err error)

func Set

func Set(key, val string) (resp *clientv3.PutResponse, err error)

func SetTTL added in v1.1.1

func SetTTL(key, val string, ttl int64) (resp *clientv3.PutResponse, err error)

func SetTTLWithPrevKV added in v1.1.1

func SetTTLWithPrevKV(key, val string, ttl int64) (resp *clientv3.PutResponse, err error)

func SetWithPrevKV added in v1.1.1

func SetWithPrevKV(key, val string) (resp *clientv3.PutResponse, err error)

func Watch

func Watch(key string) <-chan []string

Types

type Client

type Client struct {
	*clientv3.Client
	// contains filtered or unexported fields
}

func Default added in v1.1.1

func Default() *Client

func New

func New(conf Config) (cli *Client, err error)

func (*Client) Del

func (cli *Client) Del(key string, opts ...clientv3.OpOption) (resp *clientv3.DeleteResponse, err error)

del key and return previous key-value

func (*Client) DelWithPrefix added in v1.1.1

func (cli *Client) DelWithPrefix(key string) (resp *clientv3.DeleteResponse, err error)

del prefix key and return previous key-value

func (*Client) Get

func (cli *Client) Get(key string, opts ...clientv3.OpOption) (resp *clientv3.GetResponse, err error)

get value by key

func (*Client) GetArray

func (cli *Client) GetArray(key string) (data []string)

get array value by prefix key

func (*Client) GetMap

func (cli *Client) GetMap(key string) (data map[string]string)

get map value by prefix key

func (*Client) GetString added in v1.1.1

func (cli *Client) GetString(key string) string

get string value by prefix key

func (*Client) RegisterService added in v1.1.1

func (cli *Client) RegisterService(serviceName, addr string) (err error)

register service and keepalive

func (*Client) Set

func (cli *Client) Set(key, val string, opts ...clientv3.OpOption) (resp *clientv3.PutResponse, err error)

set key-value

func (*Client) SetTTL added in v1.1.1

func (cli *Client) SetTTL(key, val string, ttl int64, opts ...clientv3.OpOption) (resp *clientv3.PutResponse, err error)

set key-value-ttl

func (*Client) SetTTLWithPrevKV added in v1.1.1

func (cli *Client) SetTTLWithPrevKV(key, val string, ttl int64) (resp *clientv3.PutResponse, err error)

set key-value-ttl and return previous key-value

func (*Client) SetWithPrevKV added in v1.1.1

func (cli *Client) SetWithPrevKV(key, val string) (resp *clientv3.PutResponse, err error)

set key-value and return previous key-value

func (*Client) Watch

func (cli *Client) Watch(key string) <-chan []string

watch the key

type Config

type Config struct {
	Endpoints []string `json:"endpoints" yaml:"endpoints"`
	Username  string   `json:"username" yaml:"username"`
	Password  string   `json:"password" yaml:"password"`
	TLS       *TLS     `json:"tls" yaml:"tls"`
}

type TLS

type TLS struct {
	CertFile string `json:"cert_file" yaml:"cert_file"`
	KeyFile  string `json:"key_file" yaml:"key_file"`
	CAFile   string `json:"ca_file" yaml:"ca_file"`
}

Jump to

Keyboard shortcuts

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