Documentation
¶
Overview ¶
DNS proxy server.
TODO: understand how IPv6 routing works...
Index ¶
- Constants
- Variables
- func ApplyRequiredStateChanges(dockerClient *dockerclient.Client, etcdClient *etcd.Client, ...)
- func DeleteService(client *etcd.Client, id *ServiceIdentifier) (err error)
- func GetConfigKey(group, name string) string
- func HostIp() (ip net.IP, err error)
- func InternetRoutedIp() (ip net.IP, err error)
- func LatestInstances(etcdClient *etcd.Client, stop chan bool, numChans int, ...) (outgoing []chan map[string]*Instance)
- func LatestServiceConfigs(etcdClient *etcd.Client, stop chan bool, throttleInterval time.Duration) chan map[string]*ServiceConfig
- func LockInstance(client *etcd.Client, instance int, service *ServiceConfig) (err error)
- func PushStateChangesIntoStore(dockerClient *dockerclient.Client, etcdClient *etcd.Client, stop chan bool)
- func RequiredStateChanges(instances chan map[string]*Instance, ...) (changes chan map[string]*RequiredStateChange)
- func SetHostIp(ip net.IP)
- func SetServiceConfig(client *etcd.Client, config *ServiceConfig) (err error)
- func StartDnsServer(currentInstances chan map[string]*Instance, errorChan *chan error)
- func StartLoadBalancer(etcdClient *etcd.Client, currentInstances chan map[string]*Instance, ...)
- type Instance
- type InstanceUpdate
- type Operation
- type RequiredStateChange
- type RouteEntry
- type ServiceConfig
- type ServiceConfigUpdate
- type ServiceHttpConfig
- type ServiceIdentifier
- type ServiceState
- type SiteConfig
Constants ¶
const ( ContainerDomainSuffix = "container" ContainerDomainSuffixLen = len(ContainerDomainSuffix) + 2 )
const ( UpdateTimeToLive = 10 // Seconds LockTimeToLive = 60 // Seconds FullInstanceSyncInterval = 60 // Seconds )
const ( NginxConfigFilePerms os.FileMode = 0644 LoadBalancerWaitBetweenLaunches = 5 // Seconds )
const (
ContainerStopTimeout = 30 // seconds
)
const (
DockerWatcherPollInterval = 5 // Seconds.
)
const (
FullServiceConfigSyncInterval = 65
)
const NginxConfigurationTemplate = `` /* 282-byte string literal not displayed */
TODO: Load from file TODO: Give higher weight to backends which are on the local machine. Alternatively, mark all remote hosts as 'backup' servers.
Variables ¶
var ( Route4FilePath = "/proc/net/route" Route6FilePath = "/proc/net/ipv6_route" )
var Instances = &instances{}
var RequiredStateChangeRetry = time.Second * 15
var ServiceConfigs serviceConfigs
Functions ¶
func ApplyRequiredStateChanges ¶
func ApplyRequiredStateChanges(dockerClient *dockerclient.Client, etcdClient *etcd.Client, requiredChanges chan map[string]*RequiredStateChange, stop chan bool)
Pull required state changes from the store and attempt to apply them locally.
func DeleteService ¶
func DeleteService(client *etcd.Client, id *ServiceIdentifier) (err error)
Removes a service.
func GetConfigKey ¶
func InternetRoutedIp ¶
func LatestInstances ¶
func LatestInstances(etcdClient *etcd.Client, stop chan bool, numChans int, throttleInterval time.Duration) (outgoing []chan map[string]*Instance)
Broadcasts the latest instance updates to the output channels. Multiple subsequent messages to any given channel are suppressed and only the latest value is made available for consumers.
func LatestServiceConfigs ¶
func LatestServiceConfigs(etcdClient *etcd.Client, stop chan bool, throttleInterval time.Duration) chan map[string]*ServiceConfig
Sends the latest service configurations to the output channel. Multiple subsequent messages are suppressed and only the latest value is made available for consumers.
func LockInstance ¶
func LockInstance(client *etcd.Client, instance int, service *ServiceConfig) (err error)
func PushStateChangesIntoStore ¶
func PushStateChangesIntoStore(dockerClient *dockerclient.Client, etcdClient *etcd.Client, stop chan bool)
func RequiredStateChanges ¶
func RequiredStateChanges(instances chan map[string]*Instance, serviceConfigs chan map[string]*ServiceConfig, stop chan bool) (changes chan map[string]*RequiredStateChange)
func SetServiceConfig ¶
func SetServiceConfig(client *etcd.Client, config *ServiceConfig) (err error)
Adds or updates service configuration.
func StartDnsServer ¶
Start a DNS server so that the addresses of service instances can be resolved.
Types ¶
type Instance ¶
type Instance struct {
Group string `json:"-"`
Service string `json:"-"`
Instance int `json:"-"`
Addrs []string
PortMappings map[string]string // Map from host port to container port.
}
func (*Instance) FullyQualifiedDomainName ¶
func (*Instance) QualifiedName ¶
type InstanceUpdate ¶
type RequiredStateChange ¶
type RequiredStateChange struct {
ServiceConfig *ServiceConfig
Operation Operation
Instance int
}
type RouteEntry ¶
type ServiceConfig ¶
type ServiceConfig struct {
ServiceIdentifier
Instances int
Container docker.Config
// The Docker container image used to pull and run the container
Http ServiceHttpConfig
}
func GetServiceConfig ¶
func GetServiceConfig(client *etcd.Client, group, name string) (config *ServiceConfig, err error)
func (*ServiceConfig) Equals ¶
func (this *ServiceConfig) Equals(other *ServiceConfig) bool
type ServiceConfigUpdate ¶
type ServiceConfigUpdate struct {
Operation Operation
ServiceConfig *ServiceConfig
}
type ServiceHttpConfig ¶
type ServiceIdentifier ¶
Uniquely identifies a service.
func (*ServiceIdentifier) FullyQualifiedDomainName ¶
func (id *ServiceIdentifier) FullyQualifiedDomainName(instance int) string
func (*ServiceIdentifier) InstanceQualifiedName ¶
func (id *ServiceIdentifier) InstanceQualifiedName(instance int) string
func (*ServiceIdentifier) Key ¶
func (id *ServiceIdentifier) Key() string
func (*ServiceIdentifier) QualifiedName ¶
func (id *ServiceIdentifier) QualifiedName() string
type ServiceState ¶
type ServiceState struct {
Service *ServiceConfig
Instances []*Instance
}
