etcd

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInstance

func GetInstance() *clientv3.Client

GetInstance 获取连接实例

func Init

func Init(conf Conf)

Init 初始化连接实例

func New

func New(conf Conf) (*clientv3.Client, error)

New 新建连接实例

func Watch

func Watch(key string, fn func(k, v []byte))

Watch 监听key

func WatchWithPrefix

func WatchWithPrefix(key string, fn func(k, v []byte))

WatchWithPrefix 监听key,带前缀

Types

type Conf

type Conf struct {
	Enable    bool        `yaml:"enable" toml:"enable" json:"enable" default:"false"` //是否启用
	Endpoints []string    `yaml:"endpoints" toml:"endpoints" json:"endpoints"`        //地址列表,如: localhost:2379
	Username  string      `yaml:"username" toml:"username" json:"username"`           //账号
	Password  string      `yaml:"password" toml:"password" json:"password"`           //密码
	Timeout   int         `yaml:"timeout" toml:"timeout" json:"timeout"`              //连接超时时间(毫秒)默认10000ms
	Tls       *tls.Config `yaml:"-" toml:"-" json:"-"`                                //tls配置
}

Jump to

Keyboard shortcuts

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