Documentation
¶
Index ¶
Constants ¶
View Source
const (
RootPath = "service/endpoint"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Register(ctx context.Context, path string, data []byte) error Discovery(ctx context.Context, path string, event chan *DiscoverEvent) }
Client 数据存储客户端接口
type DiscoverEvent ¶
type DiscoverEvent struct {
Server [][]byte
}
type RegisterDiscovery ¶
type RegisterDiscovery struct {
// contains filtered or unexported fields
}
RegisterDiscovery 服务注册和发现对象
func NewRegDisc ¶
func NewRegDisc(prefix string, cli Client) *RegisterDiscovery
NewRegDisc 创建服务注册和发现对象
func (*RegisterDiscovery) Discovery ¶
func (rd *RegisterDiscovery) Discovery(ctx context.Context, path string) (<-chan *DiscoverEvent, error)
Discovery 服务发现 DiscoverEvent 通过chan DiscoverEvent 通知服务信息变更 path:要发现的服务,比如/cc/service/endpoint/user 用户服务
func (*RegisterDiscovery) GetServicePath ¶
func (rd *RegisterDiscovery) GetServicePath(id string) string
GetServicePath 格式化服务路径
func (*RegisterDiscovery) Register ¶
func (rd *RegisterDiscovery) Register(ctx context.Context, id string, info ServerInfo) error
Register 服务注册 id 服务ID,info 服务信息
type Server ¶
Server 对应一个服务对象
func NewServerDiscover ¶
func NewServerDiscover(ctx context.Context, path string, discover RegisterDiscovery) (*Server, error)
NewServerDiscover 创建对应服务的发现对象 每个服务独立的发现对象,依赖哪些服务时,按需创建即可
Click to show internal directories.
Click to hide internal directories.