Documentation ¶
Overview ¶
Package balancer provides a balancer interface and builder, which is used to forward the request to one of the backend endpoints by the specific policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Policies ¶ added in v0.8.0
func Policies() []string
Policies returns the policies of all the registered balancers.
func Register ¶ added in v0.8.0
func Register(balancer Balancer)
Register registers the balancer.
Some balancers has been registered by default, as follow:
random roundrobin weight_random weight_roundrobin sourceip_hash leastconn
If exists, override it.
func Unregister ¶ added in v0.8.0
func Unregister(policy string)
Unregister unregisters the balancer by the policy.
If not exist, do nothing.
Types ¶
type Balancer ¶
Balancer does a balancer to forward the request to one of the backend endpoints by the specific policy.
var DefaultBalancer Balancer = roundrobin.NewBalancer("")
DefaultBalancer is the default balancer.
Directories ¶
Path | Synopsis |
---|---|
Package consistenthash provides a balancer based on the consistent hash.
|
Package consistenthash provides a balancer based on the consistent hash. |
Package leastconn provides a balancer based on the least connections.
|
Package leastconn provides a balancer based on the least connections. |
Package random provides a balancer based on the random.
|
Package random provides a balancer based on the random. |
Package retry provides a retry balancer, which will retry the rest endpoints when failing to forward the request.
|
Package retry provides a retry balancer, which will retry the rest endpoints when failing to forward the request. |
Package roundrobin provides a balancer based on the roundrobin.
|
Package roundrobin provides a balancer based on the roundrobin. |
Package sourceiphash provides a balancer based on the source-ip hash.
|
Package sourceiphash provides a balancer based on the source-ip hash. |
Click to show internal directories.
Click to hide internal directories.