MCPcopy Create free account
hub / github.com/TykTechnologies/tyk / decreaseRateAllowance

Function decreaseRateAllowance

internal/rate/smoothing.go:148–158  ·  view source on GitHub ↗
(session *apidef.RateLimitSmoothing, allowedRate int64, currentRate int64, minAllowedRate int64)

Source from the content-addressed store, hash-verified

146}
147
148func decreaseRateAllowance(session *apidef.RateLimitSmoothing, allowedRate int64, currentRate int64, minAllowedRate int64) (int64, bool) {
149 newAllowedRate := allowedRate - session.Step
150 step := float64(newAllowedRate) - session.Trigger*float64(session.Step)
151 if float64(currentRate) <= step {
152 if newAllowedRate < minAllowedRate {
153 newAllowedRate = minAllowedRate
154 }
155 return newAllowedRate, newAllowedRate != allowedRate
156 }
157 return allowedRate, false
158}

Callers 2

DoMethod · 0.85

Calls

no outgoing calls

Tested by 1