Documentation
¶
Overview ¶
Package lbcache combine balancer with resolver and cache the resolve result
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
Balancer same with loadbalance.Loadbalancer but without resolver.Result that has been cached
func (*Balancer) GetPicker ¶
func (bl *Balancer) GetPicker() loadbalance.Picker
GetPicker equal to loadbalance.Balancer without pass discovery.Result, because we cache the result
type BalancerFactory ¶
type BalancerFactory struct {
Hookable
// contains filtered or unexported fields
}
BalancerFactory 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 NewBalancerFactory ¶
func NewBalancerFactory(resolver discovery.Resolver, balancer loadbalance.Loadbalancer, opts Options) *BalancerFactory
NewBalancerFactory get or create a balancer factory for balancer instance cache key with resolver name, balancer name and options
func (*BalancerFactory) Get ¶
func (b *BalancerFactory) Get(ctx context.Context, target rpcinfo.EndpointInfo) (*Balancer, error)
Get create a new balancer if not exists
type Hookable ¶
type Hookable interface {
// register loadbalance rebalance hook for Rebalance events
RegisterRebalanceHook(func(ch *discovery.Change)) (index int)
DeregisterRebalanceHook(index int)
// register loadbalance delete hook for Delete events
RegisterDeleteHook(func(ch *discovery.Change)) (index int)
DeregisterDeleteHook(index int)
}
Hookable add hook for rebalancer events
type Options ¶
type Options struct {
// refresh discovery result timely
RefreshInterval time.Duration
// Balancer expire check interval
// we need remove idle Balancers for resource saving
ExpireInterval time.Duration
// DiagnosisService is used register info for diagnosis
DiagnosisService diagnosis.Service
// Cacheable is used to indicate that if the factory could be shared between multi clients
Cacheable bool
}
Options for create builder
Click to show internal directories.
Click to hide internal directories.