etcd

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*option)

func WithCancelCtx

func WithCancelCtx(ctx context.Context, cancel context.CancelFunc) Option

func WithMaxRetry

func WithMaxRetry(maxRetry int) Option

func WithPassword added in v0.1.10

func WithPassword(passWord string) Option

func WithRegisterServiceUri

func WithRegisterServiceUri(registerServiceUri string) Option

func WithTTL

func WithTTL(ttl int64) Option

func WithUsername added in v0.1.10

func WithUsername(userName string) Option

type RegisterEtcd

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

func NewRegisterEtcd

func NewRegisterEtcd(options ...Option) (*RegisterEtcd, error)

func (*RegisterEtcd) Deregister

func (r *RegisterEtcd) Deregister(ctx context.Context, service *register.ServiceInstance) error

Deregister 取消注册

func (*RegisterEtcd) GetService

func (r *RegisterEtcd) GetService(ctx context.Context, serviceName string) ([]*register.ServiceInstance, error)

GetService 从 etcd 中获取服务

func (*RegisterEtcd) Register

func (r *RegisterEtcd) Register(ctx context.Context, service *register.ServiceInstance) error

Register 注册

func (*RegisterEtcd) Watch

func (r *RegisterEtcd) Watch(ctx context.Context, serviceName string) (register.IWatcher, error)

Watch 监测服务

type Watcher

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

func (*Watcher) Next

func (w *Watcher) Next() ([]*register.ServiceInstance, error)

Next 分两种情况 1. 第一次是立刻返回当前集群状态 2. 服务有更新的话,返回,无更新则阻塞

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop 停止监听

Jump to

Keyboard shortcuts

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