Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/bradenaw/backpressure
/ functions
Functions
61 in github.com/bradenaw/backpressure
⨍
Functions
61
◇
Types & classes
18
↓ 17 callers
Method
get
(now time.Time)
decay.go:51
↓ 16 callers
Method
add
(now time.Time, x float64)
decay.go:20
↓ 6 callers
Method
Acquire
Acquire attempts to acquire some number of tokens from the semaphore on behalf of the given priority. If Acquire returns nil, these tokens should be r
semaphore.go:151
↓ 6 callers
Method
Wait
Wait blocks until the given number of tokens is available for the given priority. It returns nil if the tokens were successfully acquired or ErrReject
rate_limiter.go:173
↓ 4 callers
Method
admit
(now time.Time)
rate_limiter.go:301
↓ 4 callers
Method
admit
(now time.Time)
semaphore.go:289
↓ 4 callers
Function
newWindowedCounter
(now time.Time, width time.Duration, n int)
windowed_counter.go:25
↓ 4 callers
Method
refill
(now time.Time)
rate_limiter.go:293
↓ 4 callers
Method
setMode
setMode appropriately sets the codelMode. Called internally.
codel.go:106
↓ 3 callers
Function
AcceptedError
AcceptedError wraps the given err as "accepted" by the backend for the purposes of AdaptiveThrottle. This should be done for regular protocol errors t
adaptive_throttle.go:15
↓ 3 callers
Function
WithAdaptiveThrottle
WithAdaptiveThrottle is used to send a request to a backend using the given AdaptiveThrottle for client-rejections. If f returns an error, at conside
adaptive_throttle.go:175
↓ 3 callers
Method
empty
true if there are no waiters in the codel.
codel.go:36
↓ 2 callers
Function
NewAdaptiveThrottle
NewAdaptiveThrottle returns an AdaptiveThrottle. priorities is the number of priorities that the throttle will accept. Giving a priority outside of `
adaptive_throttle.go:90
↓ 2 callers
Function
NewRateLimiter
NewRateLimiter returns a rate limiter with the given number of priorities, allowing the given aggregate rate, and up to the given burst. That is, the
rate_limiter.go:124
↓ 2 callers
Function
NewSemaphore
NewSemaphore returns a semaphore with the given number of priorities, and will allow at most capacity concurrency. The other options do not frequentl
semaphore.go:101
↓ 2 callers
Method
Release
Release returns the given number of tokens to the semaphore. It should only be called if these tokens are known to be acquired from the semaphore with
semaphore.go:221
↓ 2 callers
Method
canAdmit
(now time.Time, p Priority, tokens int)
semaphore.go:282
↓ 2 callers
Method
floor
(now time.Time, floor float64)
decay.go:44
↓ 2 callers
Function
jitter
(d time.Duration)
semaphore_test.go:134
↓ 2 callers
Function
newCodelWaiter
(now time.Time, t T)
codel.go:133
↓ 2 callers
Method
peek
returns the next item that would be removed by pop, if there is one. calling reap, setMode, or push invalidates this value.
codel.go:42
↓ 2 callers
Method
pop
pop pops the next waiter from the codel. Returns zero, false if the next waiter has already been abandoned or if the queue is empty. popping the next
codel.go:62
↓ 2 callers
Method
push
push adds a waiter to the codel.
codel.go:85
↓ 2 callers
Method
reap
reap removes and wakes-unsuccessfully waiters that have timed out based on the current codelMode. codel assumes this will be called at least once ever
codel.go:92
↓ 2 callers
Method
setDecayPerSec
(now time.Time, decayPerSec float64)
decay.go:31
↓ 2 callers
Method
setMax
(now time.Time, max float64)
decay.go:36
↓ 2 callers
Method
wait
wait blocks until the waiter is woken up by the codel or ctx expires. returns ErrRejected if timed out by the codel.
codel.go:144
↓ 1 callers
Method
Accepted
Accepted records that a request was accepted by the backend.
adaptive_throttle.go:150
↓ 1 callers
Function
AdaptiveThrottleWindow
AdaptiveThrottleWindow sets the time window over which the throttle remembers requests for use in figuring out the success rate.
adaptive_throttle.go:80
↓ 1 callers
Method
Attempt
Attempt returns true if the request should be attempted, and false if it should be rejected.
adaptive_throttle.go:117
↓ 1 callers
Method
Close
Close frees background resources used by the rate limiter.
rate_limiter.go:279
↓ 1 callers
Method
Close
Close frees background resources used by the semaphore.
semaphore.go:269
↓ 1 callers
Function
RateLimiterDebtDecayInterval
The time it takes for 100% debt to be completely forgiven. Debt decays linearly over time since load patterns change and a previously learned debt amo
rate_limiter.go:105
↓ 1 callers
Function
RateLimiterDebtForgivePerSuccess
The proportion of debt that is forgiven for lower priorities whenever a higher-priority request succeeds, in [0, 1].
rate_limiter.go:113
↓ 1 callers
Function
RateLimiterLongTimeout
The long timeout for the internal CoDels. See the README for more on CoDel.
rate_limiter.go:97
↓ 1 callers
Function
RateLimiterShortTimeout
The short timeout for the internal CoDels. See the README for more on CoDel.
rate_limiter.go:90
↓ 1 callers
Method
Rejected
Rejected records that a request was rejected by the backend.
adaptive_throttle.go:159
↓ 1 callers
Function
SemaphoreDebtDecayInterval
The time it takes for 100% debt to be completely forgiven. Debt decays linearly over time since load patterns change and a previously learned debt amo
semaphore.go:83
↓ 1 callers
Function
SemaphoreDebtForgivePerSuccess
The proportion of debt that is forgiven for lower priorities whenever a higher-priority request succeeds, in [0, 1].
semaphore.go:91
↓ 1 callers
Function
SemaphoreLongTimeout
The long timeout for the internal CoDels. See the README for more on CoDel.
semaphore.go:75
↓ 1 callers
Function
SemaphoreShortTimeout
The short timeout for the internal CoDels. See the README for more on CoDel.
semaphore.go:68
↓ 1 callers
Method
admit
admit attempts to successfully-wake the waiter, returns true if the waiter will return nil from wait.
codel.go:163
↓ 1 callers
Method
background
()
rate_limiter.go:345
↓ 1 callers
Method
background
()
semaphore.go:250
↓ 1 callers
Method
drop
drop unsuccessfully-wakes the waiter, it will return ErrRejected from wait.
codel.go:170
↓ 1 callers
Method
get
(now time.Time)
windowed_counter.go:40
Function
AdaptiveThrottleMinimumRate
AdaptiveThrottleMinimumRate sets the minimum number of requests per second that the adaptive throttle will allow (approximately) through to the upstre
adaptive_throttle.go:72
Function
AdaptiveThrottleRatio
AdaptiveThrottleRatio sets the ratio of the measured success rate and the rate that the throttle will admit. For example, when k is 2 the throttle wil
adaptive_throttle.go:62
Method
Error
()
adaptive_throttle.go:19
Method
SetCapacity
SetCapacity sets the maximum number of outstanding tokens for the semaphore. If more tokens than this new value are already outstanding the semaphore
semaphore.go:235
Method
SetRate
(rate float64, burst float64)
rate_limiter.go:251
Function
TestAcceptedErrorNonNilIsAccepted
(t *testing.T)
adaptive_throttle_test.go:17
Function
TestAdaptiveThrottleBasic
(t *testing.T)
adaptive_throttle_test.go:41
Function
TestRateLimiterStress
(t *testing.T)
rate_limiter_test.go:14
Function
TestSemaphoreSimple
(t *testing.T)
semaphore_test.go:17
Function
TestSemaphoreStress
(t *testing.T)
semaphore_test.go:53
Function
TestWindowedCounter
(t *testing.T)
windowed_counter_test.go:8
Function
TestWindowedCounterFrequent
(t *testing.T)
windowed_counter_test.go:73
Method
Unwrap
()
adaptive_throttle.go:20
Method
add
(now time.Time, x int)
windowed_counter.go:34
Function
newCodel
(shortTimeout time.Duration, longTimeout time.Duration)
codel.go:26