Documentation ¶
Overview ¶
Package towrap wraps two versions of Traffic Ops clients to give up-to-date information, possibly using legacy API versions.
Index ¶
- Variables
- func CreateMonitorConfig(crConfig tc.CRConfig, mc *tc.TrafficMonitorConfigMap) (*tc.TrafficMonitorConfigMap, error)
- type ByteMapCache
- type ByteTime
- type CRConfigHistoryThreadsafe
- type CRConfigStat
- type TrafficOpsSessionThreadsafe
- func (s TrafficOpsSessionThreadsafe) BackupFileExists() bool
- func (s TrafficOpsSessionThreadsafe) CRConfigHistory() []CRConfigStat
- func (s TrafficOpsSessionThreadsafe) CRConfigRaw(cdn string) ([]byte, error)
- func (s *TrafficOpsSessionThreadsafe) CRConfigValid(crc *tc.CRConfig, cdn string) error
- func (s TrafficOpsSessionThreadsafe) Initialized() bool
- func (s TrafficOpsSessionThreadsafe) LastCRConfig(cdn string) ([]byte, time.Time, error)
- func (s TrafficOpsSessionThreadsafe) MonitorCDN(hostName string) (string, error)
- func (s TrafficOpsSessionThreadsafe) TrafficMonitorConfigMap(cdn string) (*tc.TrafficMonitorConfigMap, error)
- func (s *TrafficOpsSessionThreadsafe) Update(url string, username string, password string, insecure bool, userAgent string, ...) error
Constants ¶
This section is empty.
Variables ¶
var ErrNilSession = errors.New("nil session")
ErrNilSession is the error returned by operations performed on a nil session.
Functions ¶
func CreateMonitorConfig ¶
func CreateMonitorConfig(crConfig tc.CRConfig, mc *tc.TrafficMonitorConfigMap) (*tc.TrafficMonitorConfigMap, error)
CreateMonitorConfig modifies the passed TrafficMonitorConfigMap to add the Traffic Monitors and Delivery Services found in a CDN Snapshot
Types ¶
type ByteMapCache ¶
type ByteMapCache struct {
// contains filtered or unexported fields
}
ByteMapCache is a thread-access-safe map of cache server hostnames to ByteTime structures.
func NewByteMapCache ¶
func NewByteMapCache() ByteMapCache
NewByteMapCache constructs a new, empty ByteMapCache.
func (ByteMapCache) Get ¶
func (c ByteMapCache) Get(key string) ([]byte, time.Time, *tc.CRConfigStats)
Get retrieves the raw data, associated time, and statistics of the entry given by 'key'.
func (ByteMapCache) Set ¶
func (c ByteMapCache) Set(key string, newBytes []byte, stats *tc.CRConfigStats)
Set sets the entry given by 'key' to a new ByteTime structure with the given raw data ('newBytes') and the given statistics ('stats') at the current time.
type ByteTime ¶
type ByteTime struct {
// contains filtered or unexported fields
}
ByteTime is a structure for associating a set of raw data with some CDN Snapshot statistics, and a certain time.
type CRConfigHistoryThreadsafe ¶
type CRConfigHistoryThreadsafe struct {
// contains filtered or unexported fields
}
CRConfigHistoryThreadsafe stores history in a circular buffer.
func NewCRConfigHistoryThreadsafe ¶
func NewCRConfigHistoryThreadsafe(limit uint64) CRConfigHistoryThreadsafe
NewCRConfigHistoryThreadsafe constructs a new, empty CRConfigHistoryThreadsafe - this is the ONLY way to safely create a CRConfigHistoryThreadsafe, using the zero value of the structure will cause all operations to encounter segmentation faults, and there is no way to preempt this.
'limit' indicates the size of the circular buffer - effectively the number of entries it will be capable of storing.
func (CRConfigHistoryThreadsafe) Add ¶
func (h CRConfigHistoryThreadsafe) Add(i *CRConfigStat)
Add adds the given stat to the history. Does not add new additions with the same remote address and CRConfig Date as the previous.
func (CRConfigHistoryThreadsafe) Get ¶
func (h CRConfigHistoryThreadsafe) Get() []CRConfigStat
Get retrieves the stored history of CRConfigStat entries.
func (CRConfigHistoryThreadsafe) Len ¶
func (h CRConfigHistoryThreadsafe) Len() uint64
Len gives the number of currently stored items in the buffer.
An uninitialized buffer has zero length.
type CRConfigStat ¶
type CRConfigStat struct { // Err contains any error that may have occurred when obtaining the // statistics. Err error `json:"error"` // ReqAddr is the network address from which the statistics were requested. ReqAddr string `json:"request_address"` // ReqTime is the time at which the request for statistics was made. ReqTime time.Time `json:"request_time"` // Stats contains the actual statistics. Stats tc.CRConfigStats `json:"stats"` }
CRConfigStat represents a set of statistics from a CDN Snapshot requested at a particular time.
func CopyCRConfigStat ¶
func CopyCRConfigStat(old []CRConfigStat) []CRConfigStat
CopyCRConfigStat makes a deep copy of a slice of CRConfigStats.
type TrafficOpsSessionThreadsafe ¶
type TrafficOpsSessionThreadsafe struct { CRConfigBackupFile string TMConfigBackupFile string // contains filtered or unexported fields }
TrafficOpsSessionThreadsafe provides access to the Traffic Ops client safe for multiple goroutines. This fulfills the ITrafficOpsSession interface.
func NewTrafficOpsSessionThreadsafe ¶
func NewTrafficOpsSessionThreadsafe(s *client.Session, ls *legacyClient.Session, histLimit uint64, cfg config.Config) TrafficOpsSessionThreadsafe
NewTrafficOpsSessionThreadsafe returns a new threadsafe TrafficOpsSessionThreadsafe wrapping the given `Session`.
func (TrafficOpsSessionThreadsafe) BackupFileExists ¶
func (s TrafficOpsSessionThreadsafe) BackupFileExists() bool
func (TrafficOpsSessionThreadsafe) CRConfigHistory ¶
func (s TrafficOpsSessionThreadsafe) CRConfigHistory() []CRConfigStat
CRConfigHistory gets all of the stored, historical data about CRConfig Snapshots' Stats sections.
func (TrafficOpsSessionThreadsafe) CRConfigRaw ¶
func (s TrafficOpsSessionThreadsafe) CRConfigRaw(cdn string) ([]byte, error)
CRConfigRaw returns the CRConfig from the Traffic Ops. This is safe for multiple goroutines.
func (*TrafficOpsSessionThreadsafe) CRConfigValid ¶
func (s *TrafficOpsSessionThreadsafe) CRConfigValid(crc *tc.CRConfig, cdn string) error
CRConfigValid checks if the passed tc.CRConfig structure is valid, and ensures that it is from the same CDN as the last CRConfig Snapshot, as well as that it is newer than the last CRConfig Snapshot.
func (TrafficOpsSessionThreadsafe) Initialized ¶
func (s TrafficOpsSessionThreadsafe) Initialized() bool
Initialized tells whether or not the TrafficOpsSessionThreadsafe has been properly initialized with non-nil sessions.
func (TrafficOpsSessionThreadsafe) LastCRConfig ¶
LastCRConfig returns the last CRConfig requested from CRConfigRaw, and the time it was returned. This is designed to be used in conjunction with a poller which regularly calls CRConfigRaw. If no last CRConfig exists, because CRConfigRaw has never been called successfully, this calls CRConfigRaw once to try to get the CRConfig from Traffic Ops.
func (TrafficOpsSessionThreadsafe) MonitorCDN ¶
func (s TrafficOpsSessionThreadsafe) MonitorCDN(hostName string) (string, error)
MonitorCDN returns the name of the CDN of a Traffic Monitor with the given hostName.
func (TrafficOpsSessionThreadsafe) TrafficMonitorConfigMap ¶
func (s TrafficOpsSessionThreadsafe) TrafficMonitorConfigMap(cdn string) (*tc.TrafficMonitorConfigMap, error)
TrafficMonitorConfigMap returns the Traffic Monitor config map from the Traffic Ops. This is safe for multiple goroutines.
func (*TrafficOpsSessionThreadsafe) Update ¶
func (s *TrafficOpsSessionThreadsafe) Update( url string, username string, password string, insecure bool, userAgent string, useCache bool, timeout time.Duration, ) error
Update updates the TrafficOpsSessionThreadsafe's connection information with the provided information. It's safe for calling by multiple goroutines, being aware that they will race.