Add sticky support to DRR lb
This commit is contained in:
parent
dc52abf4ce
commit
d78c419627
1 changed files with 11 additions and 3 deletions
14
server.go
14
server.go
|
@ -546,11 +546,21 @@ func (server *Server) loadConfig(configurations configs, globalConfiguration Glo
|
|||
}
|
||||
|
||||
stickysession := configuration.Backends[frontend.Backend].LoadBalancer.Sticky
|
||||
if stickysession {
|
||||
sticky := roundrobin.NewStickySession(cookiename)
|
||||
cookiename := "_TRAEFIK_SERVERNAME"
|
||||
|
||||
}
|
||||
|
||||
switch lbMethod {
|
||||
case types.Drr:
|
||||
log.Debugf("Creating load-balancer drr")
|
||||
rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger))
|
||||
if stickysession {
|
||||
log.Debugf("... setting to sticky session with cookie named %v", cookiename)
|
||||
rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger), roundrobin.RebalancerStickySession(sticky))
|
||||
} else {
|
||||
rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger))
|
||||
}
|
||||
lb = rebalancer
|
||||
for serverName, server := range configuration.Backends[frontend.Backend].Servers {
|
||||
url, err := url.Parse(server.URL)
|
||||
|
@ -570,9 +580,7 @@ func (server *Server) loadConfig(configurations configs, globalConfiguration Glo
|
|||
case types.Wrr:
|
||||
log.Debugf("Creating load-balancer wrr")
|
||||
if stickysession {
|
||||
cookiename := "_TRAEFIK_SERVERNAME"
|
||||
log.Debugf("... setting to sticky session with cookie named %v", cookiename)
|
||||
sticky := roundrobin.NewStickySession(cookiename)
|
||||
rr, _ = roundrobin.New(saveBackend, roundrobin.EnableStickySession(sticky))
|
||||
}
|
||||
lb = rr
|
||||
|
|
Loading…
Reference in a new issue