Documentation ¶
Overview ¶
Package balancer implements tiered pooling behavior across resolved backends.
Index ¶
- type Backend
- func (b *Backend) Addr() net.Addr
- func (b *Backend) AssignTier(latency time.Duration, tier int)
- func (b *Backend) Disable()
- func (b *Backend) ForcePromotionAfter() time.Duration
- func (b *Backend) MarshalYAML() (interface{}, error)
- func (b *Backend) MaxLoad() int
- func (b *Backend) String() string
- func (b *Backend) Tier() int
- type BackendToken
- type Balancer
- func (b *Balancer) Config() *config.BackendPool
- func (b *Balancer) Configure(ctx context.Context, cfg config.BackendPool, tolerateErrors bool) error
- func (b *Balancer) IsOverloaded(backend *Backend) bool
- func (b *Balancer) MarshalYAML() (interface{}, error)
- func (b *Balancer) Pick() *BackendToken
- func (b *Balancer) Rebalance(context.Context)
- func (b *Balancer) String() string
- func (b *Balancer) Wait(ctx context.Context) (*BackendToken, error)
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
A Backend creates connections to one specific backend (e.g. a TCP connection to a specific IP address).
func (*Backend) AssignTier ¶ added in v0.1.4
AssignTier (re-)assigns a Backend to a tier based on a latency metric.
func (*Backend) Disable ¶ added in v0.1.4
func (b *Backend) Disable()
Disable takes the Backend out of rotation for the configured duration.
func (*Backend) ForcePromotionAfter ¶ added in v0.1.2
ForcePromotionAfter indicates that clients should be forcefully disconnected from this backend if a better choice is available.
func (*Backend) MarshalYAML ¶ added in v0.1.2
MarshalYAML implements yaml.Marshaler interfare and provides a diagnostic view of the Backend.
type BackendToken ¶ added in v0.1.3
BackendToken is a typesafe wrapper around pool.Token.
func (*BackendToken) Balancer ¶ added in v0.1.3
func (t *BackendToken) Balancer() *Balancer
Balancer returns the owner.
func (*BackendToken) Entry ¶ added in v0.1.3
func (t *BackendToken) Entry() *Backend
Entry provides type safety around Token.Entry.
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
A Balancer implements pooling behavior across resolved backends.
func (*Balancer) Config ¶
func (b *Balancer) Config() *config.BackendPool
Config returns the currently-active configuration.
func (*Balancer) Configure ¶
func (b *Balancer) Configure(ctx context.Context, cfg config.BackendPool, tolerateErrors bool) error
Configure will initialize or update the pool configuration and attempt to resolve the targets.
func (*Balancer) IsOverloaded ¶ added in v0.1.3
IsOverloaded returns true if the given backend should be considered to be in an overload situation (e.g. when draining).
func (*Balancer) MarshalYAML ¶ added in v0.1.2
MarshalYAML implements yaml.Marshaler and provides a diagnostic view of the Balancer.
func (*Balancer) Pick ¶
func (b *Balancer) Pick() *BackendToken
Pick returns the next best choice from the pool or nil if one is not available.