You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/selector/balancer.go

38 lines
738 B

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
// Raw returns the original node
Raw() 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
}