2015-11-01 15:35:01 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// Backend holds backend configuration.
|
2015-11-01 15:35:01 +00:00
|
|
|
type Backend struct {
|
|
|
|
Servers map[string]Server `json:"servers,omitempty"`
|
|
|
|
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"`
|
|
|
|
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`
|
2016-04-13 08:11:36 +00:00
|
|
|
MaxConn *MaxConn `json:"maxConn,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// MaxConn holds maximum connection configuraiton
|
|
|
|
type MaxConn struct {
|
|
|
|
Amount int64 `json:"amount,omitempty"`
|
|
|
|
ExtractorFunc string `json:"extractorFunc,omitempty"`
|
2015-11-01 15:35:01 +00:00
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// LoadBalancer holds load balancing configuration.
|
2015-11-01 15:35:01 +00:00
|
|
|
type LoadBalancer struct {
|
|
|
|
Method string `json:"method,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// CircuitBreaker holds circuit breaker configuration.
|
2015-11-01 15:35:01 +00:00
|
|
|
type CircuitBreaker struct {
|
|
|
|
Expression string `json:"expression,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// Server holds server configuration.
|
2015-11-01 15:35:01 +00:00
|
|
|
type Server struct {
|
|
|
|
URL string `json:"url,omitempty"`
|
|
|
|
Weight int `json:"weight,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// Route holds route configuration.
|
2015-11-01 15:35:01 +00:00
|
|
|
type Route struct {
|
2016-03-27 00:05:17 +00:00
|
|
|
Rule string `json:"rule,omitempty"`
|
2016-03-30 17:05:43 +00:00
|
|
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
|
|
|
// TODO: backwards compatibility with DEPRECATED rule.Value
|
|
|
|
Value string `json:"value,omitempty"`
|
|
|
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
2015-11-01 15:35:01 +00:00
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// Frontend holds frontend configuration.
|
2015-11-01 15:35:01 +00:00
|
|
|
type Frontend struct {
|
2016-01-29 19:34:17 +00:00
|
|
|
EntryPoints []string `json:"entryPoints,omitempty"`
|
2015-11-01 15:35:01 +00:00
|
|
|
Backend string `json:"backend,omitempty"`
|
|
|
|
Routes map[string]Route `json:"routes,omitempty"`
|
|
|
|
PassHostHeader bool `json:"passHostHeader,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// LoadBalancerMethod holds the method of load balancing to use.
|
2015-11-01 15:35:01 +00:00
|
|
|
type LoadBalancerMethod uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Wrr (default) = Weighted Round Robin
|
|
|
|
Wrr LoadBalancerMethod = iota
|
|
|
|
// Drr = Dynamic Round Robin
|
|
|
|
Drr
|
|
|
|
)
|
|
|
|
|
|
|
|
var loadBalancerMethodNames = []string{
|
|
|
|
"Wrr",
|
|
|
|
"Drr",
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// NewLoadBalancerMethod create a new LoadBalancerMethod from a given LoadBalancer.
|
2015-11-01 15:35:01 +00:00
|
|
|
func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, error) {
|
|
|
|
if loadBalancer != nil {
|
|
|
|
for i, name := range loadBalancerMethodNames {
|
|
|
|
if strings.EqualFold(name, loadBalancer.Method) {
|
|
|
|
return LoadBalancerMethod(i), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Wrr, ErrInvalidLoadBalancerMethod
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// ErrInvalidLoadBalancerMethod is thrown when the specified load balancing method is invalid.
|
2015-11-01 15:35:01 +00:00
|
|
|
var ErrInvalidLoadBalancerMethod = errors.New("Invalid method, using default")
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// Configuration of a provider.
|
2015-11-01 15:35:01 +00:00
|
|
|
type Configuration struct {
|
|
|
|
Backends map[string]*Backend `json:"backends,omitempty"`
|
|
|
|
Frontends map[string]*Frontend `json:"frontends,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-11-01 18:15:05 +00:00
|
|
|
// ConfigMessage hold configuration information exchanged between parts of traefik.
|
2015-11-01 15:35:01 +00:00
|
|
|
type ConfigMessage struct {
|
|
|
|
ProviderName string
|
|
|
|
Configuration *Configuration
|
|
|
|
}
|