Documentation
¶
Index ¶
- Constants
- Variables
- func Validate(validators []ValidatorFunc) error
- type Command
- type Config
- type Controller
- type Dnsconfig
- type Endpoint
- type HealthCheck
- type Registry
- type Service
- type ValidatorFunc
- func IsInRange(name string, value, min, max int) ValidatorFunc
- func IsInRangeDuration(name string, value, min, max time.Duration) ValidatorFunc
- func IsInSet(name, value string, set []string) ValidatorFunc
- func IsNotEmpty(name, value string) ValidatorFunc
- func IsValidDomain(name, value string) ValidatorFunc
- func IsValidURL(name, value string) ValidatorFunc
Constants ¶
const ( //TerminateProcess signal that supervisor should kill other processes and exit process on failure TerminateProcess = "terminate" //IgnoreProcess signal that supervisor should ignore this process on failure IgnoreProcess = "ignore" )
const ( HTTPHealthCheck = "http" HTTPSHealthCheck = "https" TCPHealthCheck = "tcp" CommandHealthCheck = "file" )
Health check types.
Variables ¶
var DefaultConfig = Config{ Register: false, Proxy: false, DNS: false, Service: Service{ Name: "", Tags: nil, }, Endpoint: Endpoint{ Host: "", Port: 0, Type: "http", }, Registry: Registry{ URL: "", Token: "", Poll: time.Duration(15 * time.Second), }, Controller: Controller{ URL: "", Token: "", Poll: time.Duration(15 * time.Second), }, Dnsconfig: Dnsconfig{ Port: 8053, Domain: "amalgam8", }, HealthChecks: nil, LogLevel: "info", Commands: nil, }
DefaultConfig defines default values for the various configuration options
var Flags = []cli.Flag{ cli.StringFlag{ Name: debugFlag, Usage: "Check current sidecar state via CLI command", }, cli.StringFlag{ Name: configFlag, EnvVar: envVar(configFlag), Usage: "Load configuration from file", }, cli.BoolFlag{ Name: registerFlag, EnvVar: envVar(registerFlag), Usage: "Enable automatic service registration and heartbeat", }, cli.BoolFlag{ Name: proxyFlag, EnvVar: envVar(proxyFlag), Usage: "Enable automatic service discovery and load balancing across services using NGINX", }, cli.BoolFlag{ Name: dnsFlag, EnvVar: envVar(dnsFlag), Usage: "Enable DNS server", }, cli.StringFlag{ Name: serviceFlag, EnvVar: envVar(serviceFlag), Usage: "Service name to register with", }, cli.StringFlag{ Name: endpointHostFlag, EnvVar: envVar(endpointHostFlag), Usage: "Service endpoint host name (local IP is used if none specified)", }, cli.IntFlag{ Name: endpointPortFlag, EnvVar: envVar(endpointPortFlag), Usage: "Service endpoint port", }, cli.StringFlag{ Name: endpointTypeFlag, EnvVar: envVar(endpointTypeFlag), Usage: "Service endpoint type (http, https, tcp, udp, user)", }, cli.StringFlag{ Name: registryURLFlag, EnvVar: envVar(registryURLFlag), Usage: "URL for Registry", }, cli.StringFlag{ Name: registryTokenFlag, EnvVar: envVar(registryTokenFlag), Usage: "API token for Registry", }, cli.DurationFlag{ Name: registryPollFlag, EnvVar: envVar(registryPollFlag), Usage: "Interval for polling Controller", }, cli.StringFlag{ Name: controllerURLFlag, EnvVar: envVar(controllerURLFlag), Usage: "URL for Controller service", }, cli.StringFlag{ Name: controllerTokenFlag, EnvVar: envVar(controllerTokenFlag), Usage: "Amalgam8 controller token", }, cli.DurationFlag{ Name: controllerPollFlag, EnvVar: envVar(controllerPollFlag), Usage: "Interval for polling Controller", }, cli.StringFlag{ Name: dnsConfigPortFlag, EnvVar: envVar(dnsConfigPortFlag), Usage: "DNS server port number", }, cli.StringFlag{ Name: dnsConfigDomainFlag, EnvVar: envVar(dnsConfigDomainFlag), Usage: "DNS server authorization domain name", }, cli.BoolFlag{ Name: superviseFlag, EnvVar: envVar(superviseFlag), Usage: "Deprecated - this flag is no longer required and will be ignored", }, cli.StringSliceFlag{ Name: healthchecksFlag, EnvVar: envVar(healthchecksFlag), Usage: "List of health check URLs", }, cli.StringFlag{ Name: logLevelFlag, EnvVar: envVar(logLevelFlag), Usage: "Logging level (debug, info, warn, error, fatal, panic)", }, }
Flags is the set of supported flags
Functions ¶
Types ¶
type Command ¶ added in v0.4.1
type Command struct {
Cmd []string `yaml:"cmd"`
Env []string `yaml:"env"`
OnExit string `yaml:"on_exit"`
}
Command to be managed by sidecar app supervisor
type Config ¶
type Config struct {
Register bool `yaml:"register"`
Proxy bool `yaml:"proxy"`
DNS bool `yaml:"dns"`
Service Service `yaml:"service"`
Endpoint Endpoint `yaml:"endpoint"`
Registry Registry `yaml:"registry"`
Controller Controller `yaml:"controller"`
Dnsconfig Dnsconfig `yaml:"dnsconfig"`
Supervise bool `yaml:"supervise"`
HealthChecks []HealthCheck `yaml:"healthchecks"`
LogLevel string `yaml:"log_level"`
Commands []Command `yaml:"commands"`
Debug string
}
Config stores the various configuration options for the sidecar
type Controller ¶
type Controller struct {
URL string `yaml:"url"`
Token string `yaml:"token"`
Poll time.Duration `yaml:"poll"`
}
Controller configuration
type HealthCheck ¶ added in v0.4.0
type HealthCheck struct {
Type string `yaml:"type"`
Value string `yaml:"value"`
Interval time.Duration `yaml:"interval"`
Timeout time.Duration `yaml:"timeout"`
Method string `yaml:"method"`
Code int `yaml:"code"`
Args []string `yaml:"args"`
}
HealthCheck configuration.
type Registry ¶
type Registry struct {
URL string `yaml:"url"`
Token string `yaml:"token"`
Poll time.Duration `yaml:"poll"`
}
Registry configuration
type ValidatorFunc ¶
type ValidatorFunc func() error
ValidatorFunc performs a validation check
func IsInRange ¶
func IsInRange(name string, value, min, max int) ValidatorFunc
IsInRange ensures the integer is within the specified inclusive range
func IsInRangeDuration ¶
func IsInRangeDuration(name string, value, min, max time.Duration) ValidatorFunc
IsInRangeDuration ensures the time value is between the given min and max times
func IsInSet ¶
func IsInSet(name, value string, set []string) ValidatorFunc
IsInSet ensures that the value is a member of the set
func IsNotEmpty ¶
func IsNotEmpty(name, value string) ValidatorFunc
IsNotEmpty ensures the value is not empty
func IsValidDomain ¶ added in v0.4.1
func IsValidDomain(name, value string) ValidatorFunc
IsValidDomain ensures the domain name is valid domain and that it contains only one domain.
func IsValidURL ¶
func IsValidURL(name, value string) ValidatorFunc
IsValidURL ensures that the URL is valid and has a protocol specified (http, https, etc...)