package selector import ( "context" "time" ) // Balancer is balancer interface type Balancer interface { Pick(ctx context.Context, nodes []WeightedNode) (selected WeightedNode, done DoneFunc, err error) } // BalancerBuilder build balancer type BalancerBuilder interface { Build() Balancer } // WeightedNode calculates scheduling weight in real time type WeightedNode interface { Node // Weight is the runtime calculated weight Weight() float64 // Pick the node Pick() DoneFunc // PickElapsed is time elapsed since the latest pick PickElapsed() time.Duration } // WeightedNodeBuilder is WeightedNode Builder type WeightedNodeBuilder interface { Build(Node) WeightedNode }