Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Discovery ¶
type Discovery interface { //获取服务实例 GetService(ctx context.Context, serviceName string) ([]*ServiceInstance, error) //创建服务监听器 Watch(ctx context.Context, serviceName string) (Watcher, error) }
服务发现接口
type Registrar ¶
type Registrar interface { //注册 Register(ctx context.Context, service *ServiceInstance) error //注销 Deregister(ctx context.Context, service *ServiceInstance) error }
服务注册接口
type ServiceInstance ¶
type Watcher ¶
type Watcher interface { //获取服务实例, next在下面的情况下会返回服务 //1. 第一次监听时,如果服务实例列表不为空,则返回服务实例列表 //2. 如果服务实例发生变化,则返回服务实例列表 // 如果上面两种情况都不满足,则会阻塞到context deadline或者cancel Next() ([]*ServiceInstance, error) //主动放弃监听 Stop() error }
// Watcher is service watcher.
Click to show internal directories.
Click to hide internal directories.