etcdx

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(opts ...Option) *clientv3.Client

func MustEtcdWithTimeout

func MustEtcdWithTimeout(ctx context.Context, opts ...Option) (*clientv3.Client, error)

func Optional added in v1.0.4

func Optional(opts ...Option) *clientv3.Client

Types

type Config

type Config struct {
	Endpoints []string `yaml:"endpoints"`
	Timeout   int64    `yaml:"timeout"`
	Username  string   `yaml:"username"`
	Password  string   `yaml:"password" kms:"encode"`
}

Config etcd的配置字段

type Notify

type Notify func(ev *clientv3.Event, address []string)

type Option

type Option func(*Options)

func WithConfig

func WithConfig(conf Config) Option

type Options

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

type Watcher

type Watcher struct {
	Notifies []Notify
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(client *clientv3.Client) *Watcher

func (*Watcher) AddEvent

func (r *Watcher) AddEvent(notify Notify) *Watcher

func (*Watcher) GetAddresses

func (r *Watcher) GetAddresses() []string

func (*Watcher) Run

func (r *Watcher) Run()

Run 启动节点监听机制 在刚进入函数,会先执行一遍notify函数,来处理当地址列表为空时的操作,这样我们就能够填充应用域名保证连接有效

func (*Watcher) SetPrefix

func (r *Watcher) SetPrefix(prefix string) *Watcher

Jump to

Keyboard shortcuts

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