Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultRefreshInterval = 5 * time.Second DefaultExpireInterval = 15 * time.Second )
Variables ¶
View Source
var DefaultLbOpts = Options{ RefreshInterval: DefaultRefreshInterval, ExpireInterval: DefaultExpireInterval, }
Functions ¶
This section is empty.
Types ¶
type BalancerFactory ¶
type BalancerFactory struct {
// contains filtered or unexported fields
}
func NewBalancerFactory ¶
func NewBalancerFactory(config Config) *BalancerFactory
NewBalancerFactory get or create a balancer with given target. If it has the same key(resolver.Target(target)), we will cache and reuse the Balance.
func (*BalancerFactory) GetInstance ¶
type Config ¶
type Config struct {
Resolver discovery.Resolver
Balancer Loadbalancer
LbOpts Options
}
type Loadbalancer ¶
type Loadbalancer interface {
// Pick is used to select an instance according to discovery result
Pick(discovery.Result) discovery.Instance
// Rebalance is used to refresh the cache of load balance's information
Rebalance(discovery.Result)
// Delete is used to delete the cache of load balance's information when it is expired
Delete(string)
// Name returns the name of the Loadbalancer.
Name() string
}
Loadbalancer picks instance for the given service discovery result.
func NewWeightedBalancer ¶
func NewWeightedBalancer() Loadbalancer
NewWeightedBalancer creates a loadbalancer using weighted-random algorithm.
Click to show internal directories.
Click to hide internal directories.