-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
Hi,
We were testing this library for use as we already use Chi and found an issue with the current implementation.
Currently's it first checks the status and then increments. This will create an error in the following scenario which can be replicated with a unit test.
If the request limit is say 25/sec If I get 50 requests simultaneously in the first second then it will let them through as for every request the initial value will be 0.
Instead, if we can have a way in which the current window can be incremented and retrieved along with the previous window then this can be fixed.
type LimitCounter interface {
// IncrAndGet is an atomic operation
IncrAndGet(key string, inc time.Time, get time.Time) (inc int64, get int64, err error)
}
We wanted to use Redis and the example which I stated is doable using INCR command.
Please let me know your thoughts.
diamondburned, yaronius, saifat29, micronull and pkieltyka
Metadata
Metadata
Assignees
Labels
No labels