poller

package
v7.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPollerType = PollerTypeHTTP
View Source
const PollerTypeHTTP = "http"
View Source
const PollerTypeNOOP = "noop"

Variables

This section is empty.

Functions

func AddPollerType

func AddPollerType(name string, globalInit PollerGlobalInitFunc, init PollerInitFunc, poller PollerFunc)

AddPollerType adds a poller with the given name, and the given init and poll funcs. The globalInit and init funcs may be nil; poller MUST NOT be nil.

func GetGlobalContexts

func GetGlobalContexts(cfg config.Config, appData config.StaticAppData) map[string]interface{}

GetGlobalContexts returns the global contexts corresponding to the registered pollers

Types

type CachePollInfo

type CachePollInfo struct {
	NoKeepAlive     bool
	Interval        time.Duration
	ID              string
	PollingProtocol config.PollingProtocol
	PollConfig
}

type CachePoller

type CachePoller struct {
	Config         CachePollerConfig
	ConfigChannel  chan CachePollerConfig
	TickChan       chan uint64
	GlobalContexts map[string]interface{}
	Handler        handler.Handler
}

func NewCache

func NewCache(
	tick bool,
	handler handler.Handler,
	cfg config.Config,
	appData config.StaticAppData,
) CachePoller

NewCache creates and returns a new CachePoller. If tick is false, CachePoller.TickChan() will return nil.

func (CachePoller) Poll

func (p CachePoller) Poll()

type CachePollerConfig

type CachePollerConfig struct {
	Urls            map[string]PollConfig
	Interval        time.Duration
	NoKeepAlive     bool
	PollingProtocol config.PollingProtocol
}

type HTTPPollCtx

type HTTPPollCtx struct {
	Client       *http.Client
	UserAgent    string
	NoKeepAlive  bool
	PollerID     string
	HTTPHeader   http.Header
	FormatAccept string
}

type HTTPPollGlobalCtx

type HTTPPollGlobalCtx struct {
	Client       *http.Client
	UserAgent    string
	FormatAccept string
}

type MonitorCfg

type MonitorCfg struct {
	CDN string
	Cfg tc.TrafficMonitorConfigMap
}

type MonitorConfigPoller

type MonitorConfigPoller struct {
	Session          towrap.TrafficOpsSessionThreadsafe
	SessionChannel   chan towrap.TrafficOpsSessionThreadsafe
	ConfigChannel    chan MonitorCfg
	OpsConfigChannel chan handler.OpsConfig
	Interval         time.Duration
	IntervalChan     chan time.Duration
	OpsConfig        handler.OpsConfig
}

func NewMonitorConfig

func NewMonitorConfig(interval time.Duration) MonitorConfigPoller

NewMonitorConfig Creates and returns a new MonitorConfigPoller.

func (MonitorConfigPoller) Poll

func (p MonitorConfigPoller) Poll()

type PeerPollConfig

type PeerPollConfig struct {
	URLs     []string
	Timeout  time.Duration
	Format   string
	PollType string
}

func (PeerPollConfig) Equals

func (c PeerPollConfig) Equals(other PeerPollConfig) bool

type PeerPollInfo

type PeerPollInfo struct {
	NoKeepAlive bool
	Interval    time.Duration
	ID          string
	PeerPollConfig
}

type PeerPoller

type PeerPoller struct {
	Config         PeerPollerConfig
	ConfigChannel  chan PeerPollerConfig
	GlobalContexts map[string]interface{}
	Handler        handler.Handler
}

func NewPeer

func NewPeer(
	handler handler.Handler,
	cfg config.Config,
	appData config.StaticAppData,
) PeerPoller

NewPeer creates and returns a new PeerPoller.

func (PeerPoller) Poll

func (p PeerPoller) Poll()

type PeerPollerConfig

type PeerPollerConfig struct {
	Urls        map[string]PeerPollConfig
	Interval    time.Duration
	NoKeepAlive bool
}

type PollConfig

type PollConfig struct {
	URL      string
	URLv6    string
	Host     string
	Timeout  time.Duration
	Format   string
	PollType string
}

type PollerConfig

type PollerConfig struct {
	Timeout     time.Duration
	NoKeepAlive bool
	PollerID    string
}

PollerConfig is the data given to cache pollers when they're initialized.

type PollerFunc

type PollerFunc func(ctx interface{}, url string, host string, pollID uint64) ([]byte, time.Time, time.Duration, error)

PollerFunc polls a cache. It takes the global context created by this Poller's GlobalInit, and the poller-specific context created by this poller's Init. It returns the response bytes, the time the request finished, the length of time the request took, and any error. If the PollerFunc needs the global context object, the Init func should embed it in the context object it returns. If Init is nil, the global context will be given to the poller.

type PollerGlobalInitFunc

type PollerGlobalInitFunc func(cfg config.Config, appData config.StaticAppData) interface{}

PollerGlobalInit performs global initialization, and returns a global context object. For example, a poller might create a threadsafe client object, which can be used concurrently by all pollers.

type PollerInitFunc

type PollerInitFunc func(cfg PollerConfig, globalCtx interface{}) interface{}

PollerInit performs initialization for a specific poller. It takes the global context created by the poller's GlobalInit. For example, a poller might create a template client in its GlobalInit, and then use that to create a non-threadsafe client for each concurrent poller.

type PollerType

type PollerType struct {
	GlobalInit PollerGlobalInitFunc
	Init       PollerInitFunc
	Poll       PollerFunc
}

Poller is a particular type of cache stat poller. Examples are HTTP, TCP, or NFS files. It only polls and returns bytes received, it does not do any parsing. For stat parsing, see traffic_monitor/cache/stats_types.go.

Jump to

Keyboard shortcuts

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