observers

package
v3.7.2+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Package observers contains the core logic for observers, which are what observe the environment to discover running services. An Observer only has to implement one method, Configure, which receives the configuration for that observer. That Configure method might be called multiple times, so an observer should be prepared for its config to change and take appropriate steps.

The ultimate output of an observer are objects that implement services.Endpoint, which represent the discovered service endpoints.

Index

Constants

This section is empty.

Variables

View Source
var ConfigTemplates = map[string]interface{}{}

ConfigTemplates are blank (zero-value) instances of the configuration struct for a particular observer type.

Functions

func Register

func Register(_type string, factory ObserverFactory, configTemplate interface{})

Register an observer of _type with the agent. configTemplate should be a zero-valued struct that is of the same type that is accepted by the Configure method of the observer.

Types

type ObserverFactory

type ObserverFactory func(*ServiceCallbacks) interface{}

ObserverFactory creates an unconfigured instance of an observer

type ObserverManager

type ObserverManager struct {

	// Where to send observer notifications to
	CallbackTargets *ServiceCallbacks
	// contains filtered or unexported fields
}

ObserverManager instantiates and manages the configured observers

func (*ObserverManager) Configure

func (om *ObserverManager) Configure(obsConfig []config.ObserverConfig)

Configure will do everything it can and returns any errors it encounters with certain observers. It is possible that some plugins might be configured and others not.

func (*ObserverManager) DiagnosticText

func (om *ObserverManager) DiagnosticText() string

DiagnosticText outputs human-readable text about the active observers.

func (*ObserverManager) InternalMetrics

func (om *ObserverManager) InternalMetrics() []*datapoint.Datapoint

InternalMetrics returns a list of datapoints relevant to the internal status of Observers

func (*ObserverManager) Shutdown

func (om *ObserverManager) Shutdown()

Shutdown all of the managed observers

type ObserverWrapper

type ObserverWrapper struct {
	// contains filtered or unexported fields
}

ObserverWrapper represents an active observer

func (*ObserverWrapper) Shutdown

func (ow *ObserverWrapper) Shutdown()

Shutdown calls Shutdown on the underlying observer instance if it implements it.

type ServiceCallbacks

type ServiceCallbacks struct {
	Added   func(services.Endpoint)
	Removed func(services.Endpoint)
}

ServiceCallbacks are a set of functions that the observers call upon detecting new services and disappearing services.

type ServiceDiffer

type ServiceDiffer struct {
	DiscoveryFn     func() []services.Endpoint
	IntervalSeconds int
	Callbacks       *ServiceCallbacks
	// contains filtered or unexported fields
}

ServiceDiffer will run the DiscoveryFn every IntervalSeconds and report any new or removed services to the provided Callbacks.

func (*ServiceDiffer) Start

func (sd *ServiceDiffer) Start()

Start polling the DiscoveryFn on a regular interval

func (*ServiceDiffer) Stop

func (sd *ServiceDiffer) Stop()

Stop polling the DiscoveryFn

type Shutdownable

type Shutdownable interface {
	Shutdown()
}

Shutdownable describes an observer that has a shutdown routine. Observers should implement this if they spin up any goroutines that need to be stopped.

Directories

Path Synopsis
Package docker is an observer that watches a docker daemon and reports container ports as service endpoints.
Package docker is an observer that watches a docker daemon and reports container ports as service endpoints.
Package file is a file-based observer that is primarily meant for development and test purposes.
Package file is a file-based observer that is primarily meant for development and test purposes.
Package host observer that monitors the current host for active network listeners and reports them as service endpoints Use of this observer requires the CAP_SYS_PTRACE and CAP_DAC_READ_SEARCH capability in Linux.
Package host observer that monitors the current host for active network listeners and reports them as service endpoints Use of this observer requires the CAP_SYS_PTRACE and CAP_DAC_READ_SEARCH capability in Linux.
Package kubernetes contains an observer that watches the Kubernetes API for pods that are running on the same node as the agent.
Package kubernetes contains an observer that watches the Kubernetes API for pods that are running on the same node as the agent.

Jump to

Keyboard shortcuts

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