(session *apidef.RateLimitSmoothing, allowedRate int64, currentRate int64, minAllowedRate int64)
| 146 | } |
| 147 | |
| 148 | func 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 | } |
no outgoing calls