discovery

package
v0.0.0-...-0388399 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

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

Discovery 服务发现组件

func NewDiscovery

func NewDiscovery(opts ...Option) *Discovery

NewDiscovery 创建服务发现组件

func (*Discovery) GetAll

func (c *Discovery) GetAll(name string) []*service.Service

GetAll 获取所有服务器信

func (*Discovery) Select

func (c *Discovery) Select(name string, selectors ...selector.Selector) *service.Service

Select 获取服务信息

func (*Discovery) Start

func (c *Discovery) Start(key string) error

Start 开启服务发现

func (*Discovery) Stop

func (c *Discovery) Stop() error

Stop 停止服务发现

type Event

type Event = clientv3.Event

Event 监听事件

type Option

type Option func(*Options)

Option 设置服务注册参数

func Addresses

func Addresses(addresses []string) Option

Addresses 设置etcd地址

func Password

func Password(password string) Option

Password 设置etcd密码

func Prefix

func Prefix(prefix string) Option

Prefix 设置服务发现前缀

func Selectors

func Selectors(selectors ...selector.Selector) Option

Selectors 设置服务发选择器

func Timeout

func Timeout(timeout time.Duration) Option

Timeout 设置etcd超时时间

func Username

func Username(userName string) Option

Username 设置etcd用户名

type Options

type Options struct {
	Addresses []string            // etcd地址
	Username  string              // etcd用户名
	Password  string              // etcd密码
	Prefix    string              //服务注册前缀
	Timeout   time.Duration       // etcd超时时间
	Watch     func(event *Event)  // 服务发生变化时回调函数
	Selectors []selector.Selector // 服务发现
}

Options 服务注册参数

type Watch

type Watch func(event int32, host string)

Watch watch回调函数

Jump to

Keyboard shortcuts

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