towrap

package
v5.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 14 Imported by: 0

Documentation

Overview

Package towrap wraps two versions of Traffic Ops clients to give up-to-date information, possibly using legacy API versions.

Index

Constants

This section is empty.

Variables

View Source
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, and wipe out all of those that already existed in the configuration map.

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

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

Get retrieves the stored history of CRConfigStat entries.

func (CRConfigHistoryThreadsafe) Len

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 (by calling 'Update').

func (TrafficOpsSessionThreadsafe) LastCRConfig

func (s TrafficOpsSessionThreadsafe) LastCRConfig(cdn string) ([]byte, time.Time, error)

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.

Jump to

Keyboard shortcuts

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