goetcd

package
v1.2.49 Latest Latest
Warning

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

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

README

golang operation etcd api

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

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

func GetString(key string) string

func Init

func Init(configs ...Config) (err error)

func RegisterService

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

func Set

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

func SetTTL

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

func SetTTLWithPrevKV

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

func SetWithPrevKV

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

func Watch

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

Types

type Config

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

type GoEtcdClient

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

func Default

func Default() *GoEtcdClient

func GetClient

func GetClient(names ...string) *GoEtcdClient

func New

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

func (*GoEtcdClient) Del

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

del key and return previous key-value

func (*GoEtcdClient) DelWithPrefix

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

del prefix key and return previous key-value

func (*GoEtcdClient) Get

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

get value by key

func (*GoEtcdClient) GetArray

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

get array value by prefix key

func (*GoEtcdClient) GetMap

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

get map value by prefix key

func (*GoEtcdClient) GetString

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

get string value by prefix key

func (*GoEtcdClient) RegisterService

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

register service and keepalive

func (*GoEtcdClient) Set

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

set key-value

func (*GoEtcdClient) SetTTL

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

set key-value-ttl

func (*GoEtcdClient) SetTTLWithPrevKV

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

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

func (*GoEtcdClient) SetWithPrevKV

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

set key-value and return previous key-value

func (*GoEtcdClient) Watch

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

watch the key

type TLS

type TLS struct {
	CertFile string `json:"certFile,optional" yaml:"CertFile,optional"`
	KeyFile  string `json:"keyFile,optional" yaml:"KeyFile,optional"`
	CAFile   string `json:"caFile,optional" yaml:"CAFile,optional"`
}

Jump to

Keyboard shortcuts

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