Documentation ¶
Overview ¶
Package leastconn provides a balancer based on the least connections.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GetConcurrency func(loadbalancer.Endpoint) int = func(e loadbalancer.Endpoint) int { if c, ok := e.(Concurrenter); ok { return c.Concurrent() } return 0 }
GetConcurrency is the default function to get the concurrency number of the endpoint.
For the default implementation, check whether the endpoint has implemented the interface Concurrenter and call it. Or, return 0.
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
Balancer implements the balancer based on the least number of the connection.
func NewBalancer ¶
NewBalancer returns a new balancer based on the random with the policy name.
If policy is empty, use "leastconn" instead. If getconcurrency is nil, use GetConcurrency instead.
type Concurrenter ¶ added in v0.8.0
type Concurrenter interface {
Concurrent() int
}
Concurrenter is used to return the concurrent number of an endpoint.
Click to show internal directories.
Click to hide internal directories.