Linting types package

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2015-11-01 19:15:05 +01:00
parent 89bb1ae835
commit c32f82baee

View file

@ -5,43 +5,43 @@ import (
"strings" "strings"
) )
// Backend configuration // Backend holds backend configuration.
type Backend struct { type Backend struct {
Servers map[string]Server `json:"servers,omitempty"` Servers map[string]Server `json:"servers,omitempty"`
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"` CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"`
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"` LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`
} }
// LoadBalancer configuration // LoadBalancer holds load balancing configuration.
type LoadBalancer struct { type LoadBalancer struct {
Method string `json:"method,omitempty"` Method string `json:"method,omitempty"`
} }
// CircuitBreaker configuration // CircuitBreaker holds circuit breaker configuration.
type CircuitBreaker struct { type CircuitBreaker struct {
Expression string `json:"expression,omitempty"` Expression string `json:"expression,omitempty"`
} }
// Server configuration // Server holds server configuration.
type Server struct { type Server struct {
URL string `json:"url,omitempty"` URL string `json:"url,omitempty"`
Weight int `json:"weight,omitempty"` Weight int `json:"weight,omitempty"`
} }
// Route configuration // Route holds route configuration.
type Route struct { type Route struct {
Rule string `json:"rule,omitempty"` Rule string `json:"rule,omitempty"`
Value string `json:"value,omitempty"` Value string `json:"value,omitempty"`
} }
// Frontend configuration // Frontend holds frontend configuration.
type Frontend struct { type Frontend struct {
Backend string `json:"backend,omitempty"` Backend string `json:"backend,omitempty"`
Routes map[string]Route `json:"routes,omitempty"` Routes map[string]Route `json:"routes,omitempty"`
PassHostHeader bool `json:"passHostHeader,omitempty"` PassHostHeader bool `json:"passHostHeader,omitempty"`
} }
// Load Balancer Method // LoadBalancerMethod holds the method of load balancing to use.
type LoadBalancerMethod uint8 type LoadBalancerMethod uint8
const ( const (
@ -56,6 +56,7 @@ var loadBalancerMethodNames = []string{
"Drr", "Drr",
} }
// NewLoadBalancerMethod create a new LoadBalancerMethod from a given LoadBalancer.
func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, error) { func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, error) {
if loadBalancer != nil { if loadBalancer != nil {
for i, name := range loadBalancerMethodNames { for i, name := range loadBalancerMethodNames {
@ -67,14 +68,16 @@ func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, erro
return Wrr, ErrInvalidLoadBalancerMethod return Wrr, ErrInvalidLoadBalancerMethod
} }
// ErrInvalidLoadBalancerMethod is thrown when the specified load balancing method is invalid.
var ErrInvalidLoadBalancerMethod = errors.New("Invalid method, using default") var ErrInvalidLoadBalancerMethod = errors.New("Invalid method, using default")
// Configuration of a provider // Configuration of a provider.
type Configuration struct { type Configuration struct {
Backends map[string]*Backend `json:"backends,omitempty"` Backends map[string]*Backend `json:"backends,omitempty"`
Frontends map[string]*Frontend `json:"frontends,omitempty"` Frontends map[string]*Frontend `json:"frontends,omitempty"`
} }
// ConfigMessage hold configuration information exchanged between parts of traefik.
type ConfigMessage struct { type ConfigMessage struct {
ProviderName string ProviderName string
Configuration *Configuration Configuration *Configuration