etcdclient

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnTimeout = time.Second * 3
	OperTimeout = time.Second * 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TEtcdClient

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

func Connect

func Connect(etcdAddrs []string) (*TEtcdClient, error)

*

  • 连接etcd

func GetInstance

func GetInstance() *TEtcdClient

*

  • 获取一个单例,可以用这个不需要考虑线程安全

func GetSafeInstance

func GetSafeInstance() *TEtcdClient

*

  • 获取一个线程安全的单例

func InitInstance

func InitInstance() *TEtcdClient

*

  • 初始化一个单例,一般用于程序启动时

func (*TEtcdClient) Count

func (etcd *TEtcdClient) Count(prefix string) (int64, error)

*

  • Count By prefix data

func (*TEtcdClient) Del added in v1.1.3

func (etcd *TEtcdClient) Del(key string) (int64, error)

*

  • Delete One

func (*TEtcdClient) DelAll added in v1.1.3

func (etcd *TEtcdClient) DelAll(prefix string) (int64, error)

*

  • Delete All By Prefix

func (*TEtcdClient) Get

func (etcd *TEtcdClient) Get(key string) (string, error)

*

  • Get Single Key

func (*TEtcdClient) GetAll

func (etcd *TEtcdClient) GetAll(prefix string) (map[string]string, int64, error)

*

  • Get By prefix Mutiple Key

func (*TEtcdClient) GetClient

func (etcd *TEtcdClient) GetClient() *clientv3.Client

*

  • 返回原生接口

func (*TEtcdClient) GetHead

func (etcd *TEtcdClient) GetHead() string

*

  • 连接etcd

func (*TEtcdClient) GetKV

func (etcd *TEtcdClient) GetKV() clientv3.KV

*

  • 返回原生接口

func (*TEtcdClient) GetLimit

func (etcd *TEtcdClient) GetLimit(prefix string, limit int) (map[string]string, int64, error)

*

  • Get By prefix Limit N

func (*TEtcdClient) GetMaxKey

func (etcd *TEtcdClient) GetMaxKey(prefix string) (string, error)

*

  • 获取最大键,用于获取最大ID,比如Key_001 ... Key_102 最大为Key_102

func (*TEtcdClient) GetRange

func (etcd *TEtcdClient) GetRange(startKey string, endKey string) (map[string]string, int64, error)

*

  • Get By Range,Not Contains endKey,[startKey,endKey)

func (*TEtcdClient) GetRangeLimit

func (etcd *TEtcdClient) GetRangeLimit(startKey string, limit int) (map[string]string, int64, error)

*

  • Get By Range,Contains StartKey[startKey,N-1]

func (*TEtcdClient) HGet

func (etcd *TEtcdClient) HGet(getResp *clientv3.GetResponse, err error) (map[string]string, int64, error)

*

  • hash get,获取一个map键值对结构,对于排序的结构从ectd查出来是有序的,但map不保证有序性,所以放入map后是无序的

func (*TEtcdClient) Set

func (etcd *TEtcdClient) Set(key string, value string, args ...int) error

*

  • Set Value

func (*TEtcdClient) SetHead

func (etcd *TEtcdClient) SetHead(head string)

Jump to

Keyboard shortcuts

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