Documentation ¶
Index ¶
Constants ¶
const (
CACHE_DRAIN_INTERVAL = 10 * time.Minute // Drain the cache every 10 mins
)
const (
SLEEP_INTERVAL = 1 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Discoverer ¶
type Discoverer interface { // Returns a slice of services that we discovered Services() []service.Service // Get the health check and health check args for a service HealthCheck(svc *service.Service) (string, string) // A non-blocking method that runs a discovery loop. // The controlling process kicks it off to start discovery. Run(director.Looper) }
A Discoverer is responsible for findind services that we care about. It must have a method to return the list of services, and a Run() method that will be invoked when the discovery mechanism(s) is/are started.
type DockerClient ¶
type DockerDiscovery ¶
type DockerDiscovery struct { ClientProvider func() (DockerClient, error) // Return the client we'll use to connect sync.RWMutex // Reader/Writer lock // contains filtered or unexported fields }
func NewDockerDiscovery ¶
func NewDockerDiscovery(endpoint string, svcNamer ServiceNamer) *DockerDiscovery
func (*DockerDiscovery) HealthCheck ¶
func (d *DockerDiscovery) HealthCheck(svc *service.Service) (string, string)
HealthCheck looks up a health check using Docker container labels to pass the type of check and the arguments to pass to it.
func (*DockerDiscovery) Run ¶
func (d *DockerDiscovery) Run(looper director.Looper)
The main loop, poll for containers continuously.
func (*DockerDiscovery) Services ¶
func (d *DockerDiscovery) Services() []service.Service
type DockerLabelNamer ¶
type DockerLabelNamer struct {
Label string
}
A ServiceNamer that uses a name provided in a Docker label as the name for the service.
func (*DockerLabelNamer) ServiceName ¶
func (d *DockerLabelNamer) ServiceName(container *docker.APIContainers) string
Return the value of the configured Docker label, or default to the image name.
type MultiDiscovery ¶
type MultiDiscovery struct {
Discoverers []Discoverer
}
A MultiDiscovery is a wrapper around zero or more Discoverers. It allows the use of potentially multiple Discoverers in place of one.
func (*MultiDiscovery) HealthCheck ¶
func (d *MultiDiscovery) HealthCheck(svc *service.Service) (string, string)
Get the health check and health check args for a service
func (*MultiDiscovery) Run ¶
func (d *MultiDiscovery) Run(looper director.Looper)
Kicks off the Run() method for all the discoverers.
func (*MultiDiscovery) Services ¶
func (d *MultiDiscovery) Services() []service.Service
Aggregates all the service slices from the discoverers
type RegexpNamer ¶
type RegexpNamer struct { ServiceNameMatch string // contains filtered or unexported fields }
A ServiceNamer that uses a regex to match against the service name or else uses the image as the service name.
func (*RegexpNamer) ServiceName ¶
func (r *RegexpNamer) ServiceName(container *docker.APIContainers) string
Return a properly regex-matched name for the service, or failing that, the Image ID which we use to stand in for the name of the service.
type ServiceNamer ¶
type ServiceNamer interface {
ServiceName(*docker.APIContainers) string
}
type StaticCheck ¶
type StaticDiscovery ¶
func NewStaticDiscovery ¶
func NewStaticDiscovery(filename string) *StaticDiscovery
func (*StaticDiscovery) HealthCheck ¶
func (d *StaticDiscovery) HealthCheck(svc *service.Service) (string, string)
func (*StaticDiscovery) ParseConfig ¶
func (d *StaticDiscovery) ParseConfig(filename string) ([]*Target, error)
Parses a JSON config file containing an array of Targets. These are then augmented with a random hex ID and stamped with the current UTC time as the creation time. The same hex ID is applied to the Check and the Service to make sure that they are matched by the healthy package later on.
func (*StaticDiscovery) Run ¶
func (d *StaticDiscovery) Run(looper director.Looper)
Causes the configuration to be parsed and loaded. There is no background processing needed on an ongoing basis.
func (*StaticDiscovery) Services ¶
func (d *StaticDiscovery) Services() []service.Service
Returns the list of services derived from the targets that were parsed out of the config file.
type Target ¶
type Target struct { Service service.Service Check StaticCheck }