Documentation ¶
Overview ¶
Package registry 服务注册与发现
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Selector2Director ¶
Selector2Director 将 selector.Selector 转换为 httputil.ProxyRequest.Director 字段类型的函数
func Selector2Rewrite ¶
func Selector2Rewrite(s selector.Selector) func(r *httputil.ProxyRequest)
Selector2Rewrite 将 selector.Selector 转换为 httputil.ProxyRequest.Rewrite 字段类型的函数
Types ¶
type Registry ¶
type Registry interface { // Register 注册服务 // // name 服务名称; // peer 节点信息; // // 返回一个用于注销当前服务的方法; Register(name string, peer selector.Peer) (DeregisterFunc, error) // Discover 返回指定名称的服务节点 // // name 为服务的名称; // s 为调用者关联的 [web.Server] 对象; Discover(name string, s web.Server) selector.Selector // ReverseProxy 返回 name 对应的 [httputil.ReverseProxy] ReverseProxy(string, web.Server) *httputil.ReverseProxy }
Registry 服务注册与发现需要实现的接口
type Strategy ¶
type Strategy struct { // NewSelector 构建 [selector.Updateable] NewSelector func() selector.Updateable // NewPeer 构建与 [Strategy.NewSelector] 相匹配的 [selector.Peer] 零值对象 NewPeer func() selector.Peer }
Strategy 为初始化 Registry 对象提供的方案
func NewRandomStrategy ¶
func NewRandomStrategy() *Strategy
func NewRoundRobinStrategy ¶
func NewRoundRobinStrategy() *Strategy
func NewStrategy ¶
func NewStrategy(sel func() selector.Updateable, p func() selector.Peer) *Strategy
func NewWeightedRandomStrategy ¶
func NewWeightedRandomStrategy() *Strategy
func NewWeightedRoundRobinStrategy ¶
func NewWeightedRoundRobinStrategy() *Strategy
Click to show internal directories.
Click to hide internal directories.