sources

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

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

Documentation

Overview

Package sources provides the interfaces for metric sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IsTls bool // If true, Connector connects using TLS
}

Config controls how a Connector connects.

type Connector

type Connector interface {
	Connect(host string, port uint, config Config) (Poller, error)
	Name() string
}

Connector connects to a particular type of source. Connector instances must be safe to use with multiple goroutines.

type ConnectorList

type ConnectorList []Connector

ConnectorList is a list of connectors. First element of list is most prefered; last element is least preferred. Instances of this type must be treated as immutable.

type Poller

type Poller interface {
	Poll() (metrics.List, error)
	Close() error
}

Poller polls metrics from a particular source. Generally, a Poller instance may be polled once and then must be closed.

type Resource

type Resource interface{}

Resource represents a resource to connect to.

Resource instances are long lived and therefore can amortize the cost of opening up a connection again and again from scratch using a host and port. A particular Resource instance is valid only for the ResourceConnector that created it.

type ResourceConnector

type ResourceConnector interface {
	Connector

	// Creates a long lived resource from host and port. Returned resource
	// can be passed to ResourceConnect again and again amortizing the cost
	// of connecting.
	NewResource(host string, port uint, config Config) Resource

	ResourceConnect(resource Resource) (Poller, error)
}

ResourceConnector is implemented by Connector instances that support amortizing the cost of connecting. Clients should check at runtime if a Connector instance implements this interface. If it does they should use the NewResource and ResourceConnect methods instead of the Connect method.

func AsResourceConnector

func AsResourceConnector(conn Connector) ResourceConnector

AsResourceConnector upgrades conn to a ResourceConnector.

func MultiResourceConnector

func MultiResourceConnector(
	conns ConnectorList, consecutiveCallsForReset int) ResourceConnector

MultiResourceConnector makes a ResourceConnector out of a ConnectorList. consecutiveCallsForReset is how many times an alternate Connector must be used through a Resource created from this instance before the first Connector is tried again. See preference.New in github.com/Symantec/scotty/lib/preference.

Directories

Path Synopsis
Package jsonsource connects to sources using tricorder json.
Package jsonsource connects to sources using tricorder json.
Package loadsource provides bogus metrics for load testing.
Package loadsource provides bogus metrics for load testing.
Package selfsource get metrics for current process
Package selfsource get metrics for current process
Package snmpsource connects to sources using snmp
Package snmpsource connects to sources using snmp
Package trisource connects to sources using tricorder.
Package trisource connects to sources using tricorder.

Jump to

Keyboard shortcuts

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