Documentation ¶
Overview ¶
接口文件 balancer 负载均衡
实现文件 balancernormal 负载均衡管理器,主要用于统筹管理 服务:负载均衡算法
实现文件 brandom 随机负载均衡算法实现
实现文件 balancerswrr 平滑加权负载均衡算法实现
Index ¶
Constants ¶
View Source
const ( // Name 基础的负载均衡容器实现 Name = "BalancerNormal" StrategyRandom = "strategy_random" StrategySwrr = "strategy_swrr" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IBalancer ¶
type IBalancer interface { Init() // Pick 为 target 服务选取一个合适的节点 // // strategy 选取所使用的策略,在构建阶段通过 opt 传入 Pick(strategy string, target string) (meta.Node, error) Run() Close() }
IBalancer 负载均衡器
func BuildWithOption ¶
type IPicker ¶
type IPicker interface { // Get 从当前的负载均衡算法中,选取一个匹配的节点 Get() (nod meta.Node, err error) // Add 为当前的服务添加一个新的节点 service gate : [ gate1, gate2 ] Add(meta.Node) // Rmv 从当前的服务中移除一个旧的节点 Rmv(meta.Node) // Update 更新一个当前服务中的节点(通常是权重信息 Update(meta.Node) }
IPicker 选取器
Click to show internal directories.
Click to hide internal directories.