throttle

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSkipTTLMinutes = 60
View Source
const DefaultThrottleRatio = 1.0
View Source
const DefaultThrottleTTLMinutes = 60

Variables

View Source
var StandardCheckFlags = &CheckFlags{}

Functions

This section is empty.

Types

type CheckFlags

type CheckFlags struct {
	ReadCheck         bool
	OverrideThreshold float64
	LowPriority       bool
	OKIfNotExists     bool
}

type CheckResult

type CheckResult struct {
	StatusCode int     `json:"StatusCode"`
	Value      float64 `json:"Value"`
	Threshold  float64 `json:"Threshold"`
	Error      error   `json:"-"`
	Message    string  `json:"Message"`
}

CheckResult is the result for an app inquiring on a metric. It also exports as JSON via the API

func NewCheckResult

func NewCheckResult(statusCode int, value float64, threshold float64, err error) *CheckResult

func NewErrorCheckResult

func NewErrorCheckResult(statusCode int, err error) *CheckResult

type Throttler

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

func NewThrottler

func NewThrottler() *Throttler

func (*Throttler) AppRequestMetricResult

func (throttler *Throttler) AppRequestMetricResult(appName string, storeName string, metricResultFunc base.MetricResultFunc, denyApp bool) (metricResult base.MetricResult, threshold float64)

func (*Throttler) IsAppThrottled

func (throttler *Throttler) IsAppThrottled(appName, storeName string) bool

func (*Throttler) Operate

func (throttler *Throttler) Operate()

func (*Throttler) RecentAppsMap

func (throttler *Throttler) RecentAppsMap() (result map[string](*base.RecentApp))

func (*Throttler) RecoverHost added in v1.3.0

func (throttler *Throttler) RecoverHost(hostName string)

func (*Throttler) SetLeaderFunc

func (throttler *Throttler) SetLeaderFunc(isLeaderFunc func() bool)

func (*Throttler) SetSharedDomainServicesFunc

func (throttler *Throttler) SetSharedDomainServicesFunc(sharedDomainServicesFunc func() (map[string]string, error))

func (*Throttler) SkipHost added in v1.3.0

func (throttler *Throttler) SkipHost(hostName string, expireAt time.Time)

func (*Throttler) SkippedHostsMap added in v1.3.0

func (throttler *Throttler) SkippedHostsMap() map[string]time.Time

func (*Throttler) ThrottleApp

func (throttler *Throttler) ThrottleApp(appName string, expireAt time.Time, ratio float64)

func (*Throttler) ThrottledAppsMap

func (throttler *Throttler) ThrottledAppsMap() (result map[string](*base.AppThrottle))

func (*Throttler) ThrottledAppsSnapshot

func (throttler *Throttler) ThrottledAppsSnapshot() map[string]cache.Item

func (*Throttler) UnthrottleApp

func (throttler *Throttler) UnthrottleApp(appName string)

type ThrottlerCheck

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

ThrottlerCheck provides methdos for an app checking on metrics

func NewThrottlerCheck

func NewThrottlerCheck(throttler *Throttler) *ThrottlerCheck

func (*ThrottlerCheck) AggregatedMetrics

func (check *ThrottlerCheck) AggregatedMetrics() map[string]base.MetricResult

AggregatedMetrics is a convenience acces method into throttler's `aggregatedMetricsSnapshot`

func (*ThrottlerCheck) Check

func (check *ThrottlerCheck) Check(appName string, storeType string, storeName string, remoteAddr string, flags *CheckFlags) (checkResult *CheckResult)

CheckAppStoreMetric

func (*ThrottlerCheck) MetricsHealth

func (check *ThrottlerCheck) MetricsHealth() map[string](*base.MetricHealth)

MetricsHealth is a convenience acces method into throttler's `metricsHealthSnapshot`

func (*ThrottlerCheck) SelfChecks

func (check *ThrottlerCheck) SelfChecks()

Jump to

Keyboard shortcuts

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