health

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: 14 Imported by: 15

Documentation

Index

Constants

View Source
const AvailableStr = "available"

AvailableStr is used to describe the state of a cache server that is available to serve traffic.

View Source
const (
	DeliveryServiceEventType = "DELIVERYSERVICE"
)
View Source
const UnavailableStr = "unavailable"

UnavailableStr is used to describe the state of a cache server that is not available to serve traffic.

Variables

This section is empty.

Functions

func CalcAvailability

func CalcAvailability(
	results []cache.Result,
	pollerName string,
	statResultHistory *threadsafe.ResultStatHistory,
	mc tc.TrafficMonitorConfigMap,
	toData todata.TOData,
	localCacheStatusThreadsafe threadsafe.CacheAvailableStatus,
	localStates peer.CRStatesThreadsafe,
	events ThreadsafeEvents,
	protocol config.PollingProtocol,
)

CalcAvailability calculates the availability of each cache in results. statResultHistory may be nil, in which case stats won't be used to calculate availability.

func EvalAggregate

func EvalAggregate(result cache.ResultInfo, resultStats *threadsafe.ResultStatValHistory, mc *tc.TrafficMonitorConfigMap) (bool, string, string)

EvalAggregate calculates the availability of a cache server as an aggregate of server metrics and metrics of its network interfaces.

func EvalCacheWithStatusInfo

func EvalCacheWithStatusInfo(result cache.ResultInfo, mc *tc.TrafficMonitorConfigMap, status tc.CacheStatus, serverStatus string) (bool, string, string)

EvalCacheWithStatusInfo evaluates whether the given cache should be marked available, taking the server's configured Status into account as well as its polling information.

func EvalInterface

func EvalInterface(infVitals map[string]cache.Vitals, inf tc.ServerInterfaceInfo) (bool, string)

EvalInterface returns whether the given interface should be marked available, a boolean of whether the result was over IPv4 (false means it was IPv6), a string describing why, and which stat exceeded a threshold. The `stats` may be nil, for pollers which don't poll stats. The availability of EvalCache MAY NOT be used to directly set the cache's local availability, because the threshold stats may not be part of the poller which produced the result. Rather, if the cache was previously unavailable from a threshold, it must be verified that threshold stat is in the results before setting the cache to available. The resultStats may be nil, and if so, won't be checked for thresholds. For example, the Health poller doesn't have Stats. TODO change to return a `cache.AvailableStatus`

func GetVitals

func GetVitals(newResult *cache.Result, prevResult *cache.Result, mc *tc.TrafficMonitorConfigMap)

GetVitals Gets the vitals to decide health on in the right format

Types

type Event

type Event struct {
	Time          Time   `json:"time"`
	Index         uint64 `json:"index"`
	Description   string `json:"description"`
	Name          string `json:"name"`
	Hostname      string `json:"hostname"`
	Type          string `json:"type"`
	Available     bool   `json:"isAvailable"`
	IPv4Available bool   `json:"ipv4Available"`
	IPv6Available bool   `json:"ipv6Available"`
}

Event represents an event change in aggregated data. For example, a cache being marked as unavailable.

type ThreadsafeEvents

type ThreadsafeEvents struct {
	// contains filtered or unexported fields
}

Events provides safe access for multiple goroutines readers and a single writer to a stored Events slice.

func NewThreadsafeEvents

func NewThreadsafeEvents(maxEvents uint64) ThreadsafeEvents

NewEvents creates a new single-writer-multiple-reader Threadsafe object

func (*ThreadsafeEvents) Add

func (o *ThreadsafeEvents) Add(e Event)

Add adds the given event. This is threadsafe for one writer, multiple readers. This MUST NOT be called by multiple threads, as it non-atomically fetches and adds.

func (*ThreadsafeEvents) Get

func (o *ThreadsafeEvents) Get() []Event

Get returns the internal slice of Events for reading. This MUST NOT be modified. If modification is necessary, copy the slice.

type Time

type Time time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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