Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrServicesNotFound = errors.New("services not found")
ErrServicesNotFound 服务列表为空
Functions ¶
func NewNetAddr ¶
NewNetAddr creates a new NetAddr object with the network and address provided.
Types ¶
type Discovery ¶
type Discovery interface {
// GetServices returns a list of instances
// After we obtain the service instance, we can get the currently available service instance
// from the service list according to different strategies.
GetServices(name string) ([]*Service, error)
// Get returns an available service instance based on the specified service selection strategy.
// the selection strategy is RoundRobinHandler
Get(name string, strategyHandler ...StrategyHandler) (*Service, error)
// String returns the name of the resolver.
String() string
}
Discovery service discovery interface
type NetAddr ¶
type NetAddr struct {
// contains filtered or unexported fields
}
NetAddr implements the net.Addr interface.
type Registry ¶
type Registry interface {
// Register service instance register
Register(s *Service) error
// Deregister the service goes offline when the application exit
Deregister(s *Service) error
// String returns the name of the registry
String() string
}
Registry is extension interface of service registry
type Service ¶
type Service struct {
// network name of the network (for example, "tcp", "udp")
Network string `json:"network"`
// 服务名字
Name string `json:"name"`
// 服务地址,一般来说由host:port组成
Address string `json:"address"`
// 命名服务的地址,例如:k8s的user.local.svc
NamedSvcAddress string `json:"named_svc_address"`
// 服务的唯一标识,例如uuid字符串
InstanceID string `json:"instance_id"`
// 当前版本
Version string `json:"version"`
// 创建时间
Created string `json:"created"`
// 服务的其他元信息
// Metadata map[string]string{} `json:"metadata"`
Metadata map[string]interface{} `json:"metadata"`
// 其他标签信息
Tags map[string]string `json:"tags"`
}
Service 服务基本信息
func RoundRobinHandler ¶
RoundRobinHandler returns a random service instance.
type StrategyHandler ¶
StrategyHandler service selection strategy
Click to show internal directories.
Click to hide internal directories.