Documentation ¶
Index ¶
- Constants
- func AddPollerType(name string, globalInit PollerGlobalInitFunc, init PollerInitFunc, ...)
- func GetGlobalContexts(cfg config.Config, appData config.StaticAppData) map[string]interface{}
- type CachePollInfo
- type CachePoller
- type CachePollerConfig
- type HTTPPollCtx
- type HTTPPollGlobalCtx
- type MonitorCfg
- type MonitorConfigPoller
- type PeerPollConfig
- type PeerPollInfo
- type PeerPoller
- type PeerPollerConfig
- type PollConfig
- type PollerConfig
- type PollerFunc
- type PollerGlobalInitFunc
- type PollerInitFunc
- type PollerType
Constants ¶
const DefaultPollerType = PollerTypeHTTP
const PollerTypeHTTP = "http"
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 HTTPPollGlobalCtx ¶
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 ¶
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 PollerConfig ¶
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.