discovery

package module
v0.0.0-...-ebb7ec8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: Apache-2.0 Imports: 3 Imported by: 6

README

"# discovery"

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
}

发现对象结构定义 backend: 发现后端对象

func New

func New(uris string, heartbeat time.Duration, ttl time.Duration, configopts map[string]string) (*Discovery, error)

New 构造一个服务发现对象 rawuri:后端服务发现路径 heartbeat: 心跳间隔 ttl: 节点过期阈值 configopts: 发现设置附加属性

func (*Discovery) Register

func (d *Discovery) Register(key string, buf []byte, stopCh <-chan struct{}, fn DiscoveryRegistryFunc)

Register 注册到集群服务发现, 由集群被管理节点调用 key: 集群节点唯一编码 buf: 节点附加数据, 可以为nil stopCh: 退出心跳注册 Register为非阻塞方式, 上层业务调用后需考虑阻塞, 避免应用退出.

func (*Discovery) WatchExtend

func (d *Discovery) WatchExtend(key string, stopCh <-chan struct{}, fn DiscoveryWatchExtendFunc)

WatchExtend 监视一个扩展路径 Watch 为非阻塞方式, 上层业务调用后需考虑阻塞, 避免应用退出. key: 监视路径 stopCh: 退出服务发现

func (*Discovery) WatchNodes

func (d *Discovery) WatchNodes(stopCh <-chan struct{}, fn DiscoveryWatchNodesFunc)

WatchNodes 集群监视功能, 由集群管理节点调用 Watch 为非阻塞方式, 上层业务调用后需考虑阻塞, 避免应用退出. stopCh: 退出服务发现

type DiscoveryRegistryFunc

type DiscoveryRegistryFunc func(key string, err error)

type DiscoveryWatchExtendFunc

type DiscoveryWatchExtendFunc func(key string, data []byte, err error)

type DiscoveryWatchNodesFunc

type DiscoveryWatchNodesFunc func(added backends.Entries, removed backends.Entries, err error)

Directories

Path Synopsis
kv

Jump to

Keyboard shortcuts

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