Stickiness cookie name
This commit is contained in:
parent
ed2eb7b5a6
commit
a9d4b09bdb
24 changed files with 434 additions and 224 deletions
|
@ -139,11 +139,13 @@ func (p *Provider) loadConfig() *types.Configuration {
|
|||
}
|
||||
|
||||
var KvFuncMap = template.FuncMap{
|
||||
"List": p.list,
|
||||
"ListServers": p.listServers,
|
||||
"Get": p.get,
|
||||
"SplitGet": p.splitGet,
|
||||
"Last": p.last,
|
||||
"List": p.list,
|
||||
"ListServers": p.listServers,
|
||||
"Get": p.get,
|
||||
"SplitGet": p.splitGet,
|
||||
"Last": p.last,
|
||||
"hasStickinessLabel": p.hasStickinessLabel,
|
||||
"getStickinessCookieName": p.getStickinessCookieName,
|
||||
}
|
||||
|
||||
configuration, err := p.GetConfiguration("templates/kv.tmpl", KvFuncMap, templateObjects)
|
||||
|
@ -239,3 +241,17 @@ func (p *Provider) checkConstraints(keys ...string) bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Provider) hasStickinessLabel(rootPath string) bool {
|
||||
stickiness, err := p.kvclient.Exists(rootPath + "/loadbalancer/stickiness")
|
||||
if err != nil {
|
||||
log.Debugf("Error occurs when check stickiness: %v", err)
|
||||
}
|
||||
sticky := p.get("false", rootPath, "/loadbalancer", "/sticky")
|
||||
|
||||
return stickiness || (len(sticky) != 0 && strings.EqualFold(strings.TrimSpace(sticky), "true"))
|
||||
}
|
||||
|
||||
func (p *Provider) getStickinessCookieName(rootPath string) string {
|
||||
return p.get("", rootPath, "/loadbalancer", "/stickiness", "/cookiename")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue