listeners

package
v0.0.0-...-1d9613f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

README

package listeners

This package is providing the ServiceListener concept to the agent. A ServiceListener listens for events related to services the agent should monitor.

Service

Service represents an application we can run a check against. It should be matched with a check template by the ConfigResolver. Services can only be Docker containers for now.

ServiceListener

ServiceListener monitors events related to Service lifecycles. It then formats and transmits this data to ConfigResolver.

DockerListener

DockerListener first gets current running containers and send these to ConfigResolver. Then it starts listening on the Docker event API for container activity and pass by Services mentioned in start/stop events to ConfigResolver through the corresponding channel.

TODO:

  • DockerListener calls Docker directly. We need a caching layer there.
  • support TLS
  • getHosts, getPorts and getTags need to use a caching layer for docker and use the k8s api (also with caching)
ECSListener

The ECSListener relies on the metadata APIs available within the agent container. We're listening on changes on the container list exposed through the API to discover new Services.

KubeletListener

The KubeletListener relies on the Kubelet API. We're listening on changes on the container list exposed through the API (/pods) to discover new Services.

Listeners & auto-discovery

Template variable support

| Listener | AD identifiers | Host | Port | Tag | Pid | Env |---|---|---|---|---|---| | Docker | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | ECS | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | | Kubelet | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("AD: variable not supported by listener")

ErrNotSupported is thrown if listener doesn't support the asked variable

View Source
var ServiceListenerFactories = make(map[string]ServiceListenerFactory)

ServiceListenerFactories holds the registered factories

Functions

func ComputeContainerServiceIDs

func ComputeContainerServiceIDs(cid string, image string, labels map[string]string) []string

ComputeContainerServiceIDs takes a container ID, an image (resolved to an actual name) and labels and computes the service IDs for this container service.

func Register

func Register(name string, factory ServiceListenerFactory)

Register registers a service listener factory

Types

type ID

type ID string

ID is the representation of the unique ID of a Service

type Service

type Service interface {
	GetID() ID                            // unique ID
	GetADIdentifiers() ([]string, error)  // identifiers on which templates will be matched
	GetHosts() (map[string]string, error) // network --> IP address
	GetPorts() ([]int, error)             // network ports
	GetTags() ([]string, error)           // tags
	GetPid() (int, error)                 // process identifier
}

Service represents an application we can run a check against. It should be matched with a check template by the ConfigResolver using the ADIdentifiers field.

type ServiceListener

type ServiceListener interface {
	Listen(newSvc, delSvc chan<- Service)
	Stop()
}

ServiceListener monitors running services and triggers check (un)scheduling

It holds a cache of running services, listens to new/killed services and updates its cache, and the ConfigResolver with these events.

type ServiceListenerFactory

type ServiceListenerFactory func() (ServiceListener, error)

ServiceListenerFactory builds a service listener

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL