Documentation ¶
Overview ¶
+k8s:deepcopy-gen=package
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound Not found error when Registry.GetService or Registry.GetServiceNode is called ErrNotFound = errors.New("registry: service not found") // ErrStoppedWatching Stopped watching error when watcher is stopped ErrStoppedWatching = errors.New("registry: stopped watching") )
var Get = definePlugin.Get
Get 获取插件
var Name = definePlugin.Name
Name 插件名称
var TryGet = definePlugin.TryGet
TryGet 尝试获取插件
Functions ¶
func Deregister ¶
Deregister 取消注册服务
Types ¶
type Endpoint ¶
type Endpoint struct { Name string `json:"name"` // 端点名称 Request *Value `json:"request"` // 端点请求参数 Response *Value `json:"response"` // 端点响应参数 Metadata map[string]string `json:"metadata"` // 端点元数据,以键值对的形式保存附加信息 }
Endpoint 服务端点 +k8s:deepcopy-gen=true
func (*Endpoint) DeepCopy ¶ added in v0.1.4
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.
func (*Endpoint) DeepCopyInto ¶ added in v0.1.4
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
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 ¶ added in v0.1.4
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Event.
func (*Event) DeepCopyInto ¶ added in v0.1.4
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 ¶ added in v0.1.4
MarshalText marshals the EventType to text.
func (*EventType) Set ¶ added in v0.1.1
Set converts a EventType string into a EventType value. returns error if the input string does not match known values.
func (*EventType) UnmarshalText ¶ added in v0.1.4
UnmarshalText unmarshals text to a EventType.
type Node ¶
type Node struct { Id string `json:"id"` // 节点ID Address string `json:"address"` // 节点的地址 Metadata map[string]string `json:"metadata"` // 节点元数据,以键值对的形式保存附加信息 }
Node 服务节点 +k8s:deepcopy-gen=true
func (*Node) DeepCopy ¶ added in v0.1.4
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node.
func (*Node) DeepCopyInto ¶ added in v0.1.4
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Registry ¶
type Registry interface { // Register 注册服务 Register(ctx context.Context, service Service, ttl time.Duration) error // Deregister 取消注册服务 Deregister(ctx context.Context, service Service) error // GetServiceNode 查询服务节点 GetServiceNode(ctx context.Context, serviceName, nodeId string) (*Service, error) // GetService 查询服务 GetService(ctx context.Context, serviceName string) ([]Service, error) // ListServices 查询所有服务 ListServices(ctx context.Context) ([]Service, error) // Watch 获取服务监听器 Watch(ctx context.Context, serviceName string) (Watcher, error) }
The Registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}
type Service ¶
type Service struct { Name string `json:"name"` // 服务名称 Version string `json:"version"` // 服务版本号 Metadata map[string]string `json:"metadata"` // 服务元数据,以键值对的形式保存附加信息 Endpoints []Endpoint `json:"endpoints"` // 服务端点列表 Nodes []Node `json:"nodes"` // 服务节点列表 }
Service 服务配置 +k8s:deepcopy-gen=true
func GetService ¶
func GetService(serviceCtx service.Context, ctx context.Context, serviceName string) ([]Service, error)
GetService 查询服务
func ListServices ¶
ListServices 查询所有服务
func (*Service) DeepCopy ¶ added in v0.1.4
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service.
func (*Service) DeepCopyInto ¶ added in v0.1.4
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Value ¶
type Value struct { Name string `json:"name"` // 参数名称 Type string `json:"type"` // 参数类型 Values []Value `json:"values"` // 参数的值,如果参数是复杂类型,则该字段为参数列表 }
Value 服务参数 +k8s:deepcopy-gen=true
func (*Value) DeepCopy ¶ added in v0.1.4
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Value.
func (*Value) DeepCopyInto ¶ added in v0.1.4
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.