Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Name = self.Name Using = self.Using )
var ( // ErrNotFound Not found error when IRegistry.GetService or IRegistry.GetServiceNode is called ErrNotFound = errors.New("registry: service not found") // ErrTerminated Stopped watching error when watcher is stopped ErrTerminated = errors.New("registry: watching terminated") )
Functions ¶
This section is empty.
Types ¶
type Event ¶
Event is returned by a call to Next on the watcher. Type can be create, update, delete +k8s:deepcopy-gen=true
func (*Event) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Event.
func (*Event) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type EventType ¶
type EventType int
EventType defines registry event type
func (*EventType) MarshalText ¶
MarshalText marshals the EventType to text.
func (*EventType) Set ¶
Set converts a EventType string into a EventType value. returns error if the input string does not match known values.
func (*EventType) UnmarshalText ¶
UnmarshalText unmarshals text to a EventType.
type IRegistry ¶
type IRegistry interface {
// Register 注册服务
Register(ctx context.Context, service *Service, ttl time.Duration) error
// Deregister 取消注册服务
Deregister(ctx context.Context, service *Service) error
// RefreshTTL 刷新所有服务TTL
RefreshTTL(ctx context.Context) error
// GetServiceNode 查询服务节点
GetServiceNode(ctx context.Context, serviceName string, nodeId uid.Id) (*Service, error)
// GetService 查询服务
GetService(ctx context.Context, serviceName string) (*Service, error)
// ListServices 查询所有服务
ListServices(ctx context.Context) ([]Service, error)
// Watch 监听服务变化
Watch(ctx context.Context, pattern string, revision ...int64) (IWatcher, error)
}
The IRegistry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}
type IWatcher ¶
type IWatcher interface {
// Pattern watching pattern
Pattern() string
// Next is a blocking call
Next() (*Event, error)
// Terminate stop watching
Terminate() <-chan struct{}
// Terminated stopped notify
Terminated() <-chan struct{}
}
IWatcher is an interface that returns updates about services within the registry.
type Node ¶
type Node struct {
Id uid.Id `json:"id"` // 节点ID
Address string `json:"address"` // 节点的地址
Version string `json:"version,omitempty"` // 节点的服务版本号
Meta map[string]string `json:"meta,omitempty"` // 节点元数据,以键值对的形式保存附加信息
}
Node 服务节点 +k8s:deepcopy-gen=true
func (*Node) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node.
func (*Node) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Service ¶
type Service struct {
Name string `json:"name"` // 服务名称
Nodes []Node `json:"nodes"` // 服务节点列表
Revision int64 `json:"revision,omitempty"` // 数据版本号
}
Service 服务配置 +k8s:deepcopy-gen=true
func (*Service) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service.
func (*Service) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.