
This PR adds support for loadbalancing across a group of endpoints that share the same service configuration as passed in by `OptionService`. The loadbalancer is implemented using ipvs with just round robin scheduling supported for now. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
32 lines
601 B
Go
32 lines
601 B
Go
package libnetwork
|
|
|
|
import (
|
|
"net"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
// A global monotonic counter to assign firewall marks to
|
|
// services.
|
|
fwMarkCtr uint32 = 256
|
|
fwMarkCtrMu sync.Mutex
|
|
)
|
|
|
|
type service struct {
|
|
name string // Service Name
|
|
id string // Service ID
|
|
|
|
// Map of loadbalancers for the service one-per attached
|
|
// network. It is keyed with network ID.
|
|
loadBalancers map[string]*loadBalancer
|
|
sync.Mutex
|
|
}
|
|
|
|
type loadBalancer struct {
|
|
vip net.IP
|
|
fwMark uint32
|
|
|
|
// Map of backend IPs backing this loadbalancer on this
|
|
// network. It is keyed with endpoint ID.
|
|
backEnds map[string]net.IP
|
|
}
|