Documentation ¶
Index ¶
- Constants
- func AddPollerType(name string, globalInit PollerGlobalInitFunc, init PollerInitFunc, ...)
- func File(filename string, result func([]byte, error)) (chan<- struct{}, error)
- 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 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 File ¶
FilePoller starts a goroutine polling the given file for changes. When changes occur, including an initial read, the result callback is called asynchronously. Returns a kill chan, which will kill the file poller when written to.
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( interval time.Duration, tick bool, handler handler.Handler, cfg config.Config, appData config.StaticAppData, pollingProtocol config.PollingProtocol, ) CachePoller
NewHTTP creates and returns a new CachePoller. If tick is false, CachePoller.TickChan() will return nil. TODO: rename to not "http", since it's now pluggable
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
Creates and returns a new CachePoller. If tick is false, CachePoller.TickChan() will return nil
func (MonitorConfigPoller) Poll ¶
func (p MonitorConfigPoller) Poll()
type PollConfig ¶
type PollerConfig ¶
type PollerConfig struct { URL string URLv6 string Host string 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.