base

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

This codebase originates from https://github.com/github/freno, See https://github.com/github/freno/blob/master/LICENSE

MIT License

Copyright (c) 2017 GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var AppDeniedMetric = &appDeniedMetric{}

AppDeniedMetric is a special metric indicating a "denied" situation

View Source
var ErrAppDenied = errors.New("App denied")

ErrAppDenied is seen when an app is denied access

View Source
var ErrInvalidCheckType = errors.New("Unknown throttler check type")

ErrInvalidCheckType is an internal error indicating an unknown check type

View Source
var ErrNoSuchMetric = errors.New("No such metric")

ErrNoSuchMetric is for when a user requests a metric by an unknown metric name

View Source
var ErrThresholdExceeded = errors.New("Threshold exceeded")

ErrThresholdExceeded is the common error one may get checking on metric result

View Source
var NoHostsMetricResult = &noHostsMetricResult{}

NoHostsMetricResult is a result indicating "no hosts"

View Source
var NoMetricResultYet = &noMetricResultYet{}

NoMetricResultYet is a result indicating "no data"

View Source
var NoSuchMetric = &noSuchMetric{}

NoSuchMetric is a metric results for an unknown metric name

Functions

func IsDialTCPError

func IsDialTCPError(e error) bool

IsDialTCPError sees if the given error indicates a TCP issue

func SetupHTTPClient

func SetupHTTPClient(httpTimeout time.Duration) *http.Client

SetupHTTPClient creates a simple HTTP client with timeout

Types

type AppThrottle

type AppThrottle struct {
	AppName  string
	ExpireAt time.Time
	Ratio    float64
	Exempt   bool
}

AppThrottle is the definition for an app throttling instruction - Ratio: [0..1], 0 == no throttle, 1 == fully throttle

func NewAppThrottle

func NewAppThrottle(appName string, expireAt time.Time, ratio float64, exempt bool) *AppThrottle

NewAppThrottle creates an AppThrottle struct

type MetricHealth

type MetricHealth struct {
	LastHealthyAt           time.Time
	SecondsSinceLastHealthy int64
}

MetricHealth is a health status for a metric, and more specifically, when it was last checked to be "OK"

func NewMetricHealth

func NewMetricHealth(lastHealthyAt time.Time) *MetricHealth

NewMetricHealth returns a MetricHealth

type MetricHealthMap

type MetricHealthMap map[string](*MetricHealth)

MetricHealthMap maps metric names to metric healths

func (MetricHealthMap) Aggregate

func (m MetricHealthMap) Aggregate(other MetricHealthMap) MetricHealthMap

Aggregate another map into this map, take the worst metric of the two

type MetricResult

type MetricResult interface {
	Get() (float64, error)
}

MetricResult is what we expect our probes to return. This can be a numeric result, or a special type of result indicating more meta-information

func NewSimpleMetricResult

func NewSimpleMetricResult(value float64) MetricResult

NewSimpleMetricResult creates a simpleMetricResult

type MetricResultFunc

type MetricResultFunc func() (metricResult MetricResult, threshold float64)

MetricResultFunc is a function that returns a metric result

type RecentApp

type RecentApp struct {
	CheckedAtEpoch      int64
	MinutesSinceChecked int64
}

RecentApp indicates when an app was last checked

func NewRecentApp

func NewRecentApp(checkedAt time.Time) *RecentApp

NewRecentApp creates a RecentApp

Jump to

Keyboard shortcuts

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