discovery

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const REGISTRY_REFRESH_INTERVAL = 30

Variables

View Source
var DoNothingClient = new(EmptyClient)

Functions

This section is empty.

Types

type Client added in v1.2.5

type Client interface {
	// 直接向远程注册中心查询所有服务实例
	QueryServices() ([]*InstanceInfo, error)

	// 注册自己
	Register() error

	// 取消注册自己
	UnRegister() error

	// 从本地缓存中查询指定服务的全部实例信息
	Get(string) []*InstanceInfo

	// 启动注册信息定时刷新逻辑
	StartPeriodicalRefresh() error

	// 获取内部保存的注册表
	GetInternalRegistryStore() *InsInfoArrSyncMap

	// 更新内部保存的注册表
	SetInternalRegistryStore(*InsInfoArrSyncMap)
}

服务发现客户端接口

func NewConsulClient added in v1.2.5

func NewConsulClient() (Client, error)

func NewEurekaClient added in v1.2.5

func NewEurekaClient(confFile string) (Client, error)

type ConsulClient added in v1.2.5

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

func (*ConsulClient) Get added in v1.3.0

func (c *ConsulClient) Get(serviceId string) []*InstanceInfo

func (*ConsulClient) GetInternalRegistryStore added in v1.3.0

func (c *ConsulClient) GetInternalRegistryStore() *InsInfoArrSyncMap

func (*ConsulClient) QueryServices added in v1.2.5

func (c *ConsulClient) QueryServices() ([]*InstanceInfo, error)

func (*ConsulClient) Register added in v1.2.5

func (c *ConsulClient) Register() error

func (*ConsulClient) SetInternalRegistryStore added in v1.3.0

func (c *ConsulClient) SetInternalRegistryStore(registry *InsInfoArrSyncMap)

func (*ConsulClient) StartPeriodicalRefresh added in v1.3.0

func (c *ConsulClient) StartPeriodicalRefresh() error

func (*ConsulClient) UnRegister added in v1.2.5

func (c *ConsulClient) UnRegister() error

type EmptyClient added in v1.3.0

type EmptyClient struct {
}

func (EmptyClient) Get added in v1.3.0

func (e EmptyClient) Get(string) []*InstanceInfo

func (EmptyClient) GetInternalRegistryStore added in v1.3.0

func (e EmptyClient) GetInternalRegistryStore() *InsInfoArrSyncMap

func (EmptyClient) QueryServices added in v1.3.0

func (e EmptyClient) QueryServices() ([]*InstanceInfo, error)

func (EmptyClient) Register added in v1.3.0

func (e EmptyClient) Register() error

func (EmptyClient) SetInternalRegistryStore added in v1.3.0

func (e EmptyClient) SetInternalRegistryStore(*InsInfoArrSyncMap)

func (EmptyClient) StartPeriodicalRefresh added in v1.3.0

func (e EmptyClient) StartPeriodicalRefresh() error

func (EmptyClient) UnRegister added in v1.3.0

func (e EmptyClient) UnRegister() error

type EurekaClient added in v1.2.5

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

func (*EurekaClient) Get added in v1.3.0

func (c *EurekaClient) Get(serviceId string) []*InstanceInfo

func (*EurekaClient) GetInternalRegistryStore added in v1.3.0

func (c *EurekaClient) GetInternalRegistryStore() *InsInfoArrSyncMap

func (*EurekaClient) QueryServices added in v1.2.5

func (c *EurekaClient) QueryServices() ([]*InstanceInfo, error)

查询所有服务

func (*EurekaClient) Register added in v1.2.5

func (c *EurekaClient) Register() error

func (*EurekaClient) SetInternalRegistryStore added in v1.3.0

func (c *EurekaClient) SetInternalRegistryStore(registry *InsInfoArrSyncMap)

func (*EurekaClient) StartPeriodicalRefresh added in v1.3.0

func (c *EurekaClient) StartPeriodicalRefresh() error

向eureka查询注册列表, 刷新本地列表

func (*EurekaClient) UnRegister added in v1.2.5

func (c *EurekaClient) UnRegister() error

type InsInfoArrSyncMap added in v1.3.0

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

封装sync.map, 提供类型安全的方法调用

func NewInsInfoArrSyncMap added in v1.3.0

func NewInsInfoArrSyncMap() *InsInfoArrSyncMap

func (*InsInfoArrSyncMap) Each added in v1.3.0

func (ism *InsInfoArrSyncMap) Each(eachFunc func(key string, val []*InstanceInfo) bool)

func (*InsInfoArrSyncMap) Get added in v1.3.0

func (ism *InsInfoArrSyncMap) Get(key string) ([]*InstanceInfo, bool)

func (*InsInfoArrSyncMap) GetMap added in v1.3.0

func (ism *InsInfoArrSyncMap) GetMap() *sync.Map

func (*InsInfoArrSyncMap) Put added in v1.3.0

func (ism *InsInfoArrSyncMap) Put(key string, val []*InstanceInfo)

type InsLbClientSyncMap added in v1.3.0

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

封装sync.map, 提供类型安全的方法调用

func NewInsMetaLbClientSyncMap added in v1.3.0

func NewInsMetaLbClientSyncMap() *InsLbClientSyncMap

func (*InsLbClientSyncMap) Get added in v1.3.0

func (ism *InsLbClientSyncMap) Get(key string) (*fasthttp.LBClient, bool)

func (*InsLbClientSyncMap) Put added in v1.3.0

func (ism *InsLbClientSyncMap) Put(key string, val *fasthttp.LBClient)

type InstanceInfo added in v1.2.0

type InstanceInfo struct {
	ServiceName string

	// 格式为 host:port
	Addr string
	// 此实例附加信息
	Meta map[string]string
}

封装服务实例信息

Jump to

Keyboard shortcuts

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