feat(ecs): add circuit Breaker label.

This commit is contained in:
Fernandez Ludovic 2017-12-16 19:51:39 +01:00 committed by Traefiker
parent 07a6d48a27
commit 66f46c5b96
2 changed files with 26 additions and 19 deletions

View file

@ -14,25 +14,27 @@ import (
// buildConfiguration fills the config template with the given instances // buildConfiguration fills the config template with the given instances
func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types.Configuration, error) { func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types.Configuration, error) {
var ecsFuncMap = template.FuncMap{ var ecsFuncMap = template.FuncMap{
"filterFrontends": filterFrontends, "filterFrontends": filterFrontends,
"getFrontendRule": p.getFrontendRule, "getFrontendRule": p.getFrontendRule,
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic), "getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
"hasLoadBalancerLabel": hasLoadBalancerLabel, "hasLoadBalancerLabel": hasLoadBalancerLabel,
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod), "getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
"getSticky": getSticky, "getSticky": getSticky,
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false), "hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
"getStickinessCookieName": getFuncFirstStringValue(label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName), "getStickinessCookieName": getFuncFirstStringValue(label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName),
"getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol), "getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol),
"getHost": getHost, "getHost": getHost,
"getPort": getPort, "getPort": getPort,
"getWeight": getFuncStringValue(label.TraefikWeight, label.DefaultWeight), "getWeight": getFuncStringValue(label.TraefikWeight, label.DefaultWeight),
"getPassHostHeader": getFuncStringValue(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader), "getPassHostHeader": getFuncStringValue(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
"getPriority": getFuncStringValue(label.TraefikFrontendPriority, label.DefaultFrontendPriority), "getPriority": getFuncStringValue(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints), "getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath), "hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""), "getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort), "getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
"getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""), "getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""),
"hasCircuitBreakerLabel": hasFuncFirst(label.TraefikBackendCircuitBreakerExpression),
"getCircuitBreakerExpression": getFuncFirstStringValue(label.TraefikBackendCircuitBreakerExpression, label.DefaultCircuitBreakerExpression),
} }
return p.GetConfiguration("templates/ecs.tmpl", ecsFuncMap, struct { return p.GetConfiguration("templates/ecs.tmpl", ecsFuncMap, struct {
Services map[string][]ecsInstance Services map[string][]ecsInstance

View file

@ -1,6 +1,11 @@
[backends] [backends]
{{range $serviceName, $instances := .Services}} {{range $serviceName, $instances := .Services}}
{{if hasCircuitBreakerLabel $instances}}
[backends.backend-{{ $serviceName }}.circuitBreaker]
expression = "{{getCircuitBreakerExpression $instances}}"
{{end}}
{{if hasLoadBalancerLabel $instances}} {{if hasLoadBalancerLabel $instances}}
[backends.backend-{{ $serviceName }}.loadBalancer] [backends.backend-{{ $serviceName }}.loadBalancer]
method = "{{ getLoadBalancerMethod $instances}}" method = "{{ getLoadBalancerMethod $instances}}"