ratelimit: per descriptor hits addend support and prefer uint64#802
ratelimit: per descriptor hits addend support and prefer uint64#802psbrar99 merged 5 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
The counter in redis is a number that counts all used tokens. So, we only need to check if the counter is larger than the threshold or not. |
|
cool, so in other words, sending hits_addend=0 can be used to reject requests if the counter in redis is negative or zero ya? |
Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
sorry, I may didn't make it clear. The counter will never be negative in the redis. It is a counter the will increases forever in the time window. But the conclusion is right. hits_addend zero could also could be used to reject a request. |
|
great, thank you for clarifying! |
Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
|
cc @psbrar99 |
|
also @zirain if you have any comments |
src/utils/utilities.go
Outdated
| } | ||
|
|
||
| func Max(a uint32, b uint32) uint32 { | ||
| func Max(a uint64, b uint64) uint64 { |
There was a problem hiding this comment.
not a must, but is it find to remove this as golang support generic?
There was a problem hiding this comment.
I am not very familiar to go (I use c++ at most times orz), so not sure if a new generic Max is provided by the golang stdlib or not. If it is provided, it would be great to remove this function.
There was a problem hiding this comment.
// The max built-in function returns the largest value of a fixed number of
// arguments of [cmp.Ordered] types. There must be at least one argument.
// If T is a floating-point type and any of the arguments are NaNs,
// max will return NaN.
func max[T cmp.Ordered](x T, y ...T) T
looks like there's.
Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
|
LGTM, thanks @wbpcode . |
|
fantastic, thank you for your hard work! @wbpcode 👯 |
No description provided.