Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New(errors.CodeGetServiceErrorNotFound, errors.MsgGetServiceErrorNotFound) ErrNoServiceName = errors.New(errors.CodeWatchServiceErrorNoServiceName, errors.MsgWatchServiceErrorNoServiceName) )
Functions ¶
This section is empty.
Types ¶
type DeRegisterOption ¶
type DeRegisterOption func(opt *DeRegisterOptions)
DeRegisterOption 注册服务参数
func DeregisterContext ¶
func DeregisterContext(ctx context.Context) DeRegisterOption
DeregisterContext 注销服务的上下文
type DeRegisterOptions ¶
type DeRegisterOptions struct { // Other options for implementations of the interface // can be stored in a context Context context.Context }
DeRegisterOptions 注销服务参数
type GetOptions ¶
GetOptions 获取服务参数
type Node ¶
type Node struct { Id string `json:"id"` // 节点id Address string `json:"address"` // 节点地址 Weight int `json:"weight"` // 节点权重 Region string `json:"region"` // 区域 Zone string `json:"zone"` // 地区 Metadata map[string]string `json:"metadata"` // 节点元信息 }
Node 节点信息
type RegisterOption ¶
type RegisterOption func(opt *RegisterOptions)
RegisterOption 注册服务参数
func RegisterContext ¶
func RegisterContext(ctx context.Context) RegisterOption
RegisterContext 设置注册服务上下文
type RegisterOptions ¶
type RegisterOptions struct { TTL time.Duration // Other options for implementations of the interface // can be stored in a context Context context.Context }
RegisterOptions 注册服务时的额外参数
type Registry ¶
type Registry interface { // Register 注册服务 Register(srv *Service, opts ...RegisterOption) error // Deregister 注销服务 Deregister(srv *Service, opts ...DeRegisterOption) error // GetService 获取服务 GetService(name string, opts ...GetOption) ([]*Service, error) // WatchService 监听服务 WatchService(opts ...WatchOption) (chan WatchServiceResult, error) // ListService 服务列表 ListService() ([]*Service, error) // String 获取注册中心类型 String() string // Close 关闭注册中心 Close() error }
Registry 注册中心接口
type Service ¶
type Service struct { Name string `json:"name"` // 服务名称 Version string `json:"version"` // 版本 Scheme string `json:"scheme"` // 服务协议 Nodes []*Node `json:"nodes"` // 所有节点信息 Metadata map[string]string `json:"metadata"` // 元信息 }
Service 服务
type WatchOptions ¶
type WatchOptions struct { Service string // 监听的服务名 Scheme string // 服务协议 Context context.Context // 上下文 }
WatchOptions 监听服务参数
type WatchServiceResult ¶
type WatchServiceResult struct {
Services []Service // 服务列表
}
WatchServiceResult 监听服务返回
func (*WatchServiceResult) DeepCopy ¶
func (w *WatchServiceResult) DeepCopy() *WatchServiceResult
Click to show internal directories.
Click to hide internal directories.