Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Balancer ¶
type Balancer interface { BalancerLite Count() int Add(peers ...Peer) Remove(peer Peer) Clear() }
Balancer represents a generic load balancer. For the real world, Balancer is a useful interface rather than BalancerLite.
type BalancerLite ¶
type BalancerLite interface { // Next will return the next backend. // // For some ones like consistent-hashed balancer, Next needs // a factor as its param. It might be the requesting URL // typically. // For else, you can pass a lbapi.DummyFactor or just an // empty string as factor. Next(factor Factor) (next Peer, c Constrainable) }
BalancerLite represents a generic load balancer.
type Constrainable ¶
type Constrainable interface { CanConstrain(o interface{}) (yes bool) Check(o interface{}) (satisfied bool) Peer }
Constrainable is an object who can be applied onto a factor ( BalancerLite.Next(factor) )
type DeepEqualAware ¶
DeepEqualAware could be concreted by a Peer so you could customize how to compare two peers, avoid reflect.DeepEqual bypass.
type Factor ¶
type Factor interface {
Factor() string
}
Factor is a factor parameter for BalancerLite.Next.
If you won't known what should be passed into BalancerLite.Next, send DummyFactor as it.
But when you are constructing a complex lb system or a multiple-level one such as a weighted versioning load balancer. Take a look at our version.New and version.VersioningBackendFactor.
type FactorComparable ¶
type FactorComparable interface { Factor ConstrainedBy(constraints interface{}) (peer Peer, c Constrainable, satisfied bool) }
FactorComparable is a composite interface which assembly Factor and constraint comparing.
type FactorHashable ¶ added in v0.3.1
FactorHashable is a composite interface which assembly Factor and hashing computer.
type FactorString ¶
type FactorString string
FactorString is a string type, it implements Factor interface.
const DummyFactor FactorString = ""
DummyFactor will be used in someone like you does not known what on earth should be passed into BalancerLite.Next(factor).
func (FactorString) Factor ¶
func (s FactorString) Factor() string
Factor function impl Factor interface
type Peer ¶
type Peer interface { // String will return the main identity string of a peer. // // You would have to implement only this one func to plug // your object into the architecture created by // lbapi.Balancer String() string }
Peer is a backend object, such as a host+port, a http/https url, or a constraint expression, and so on.
type WeightedConstrainable ¶
type WeightedConstrainable interface { Constrainable Weighted }
WeightedConstrainable is an object who can be applied onto a factor ( BalancerLite.Next(factor) )
type WeightedPeer ¶
WeightedPeer is a Peer with Weight property.