[ETCM-266]-replaced-rate-limiter-built-on-twitter#873
[ETCM-266]-replaced-rate-limiter-built-on-twitter#873dmitry-worker merged 15 commits intodevelopfrom
Conversation
2dd8457 to
cf27856
Compare
| } | ||
| ) | ||
| if (exists) { | ||
| val err = JsonRpcError.RateLimitError(minInterval) |
There was a problem hiding this comment.
Can we separate LRU cache from RateLimit'ing?
I believe there are some rate-limiting capabilities built-in cats or Akka maybe we could use sth that is already build in?
There was a problem hiding this comment.
I'm not sure I can get the idea of separating.
Do you mean an ability to plug an opt-in rate limiting engine?
| extractClientIP { ip => | ||
| if (isBelowRateLimit(ip)) { | ||
| val err = JsonRpcError.RateLimitError(minInterval) | ||
| complete((StatusCodes.TooManyRequests, err)) |
There was a problem hiding this comment.
Just a minor comment, we can reduce this line:
complete((StatusCodes.TooManyRequests, JsonRpcError.RateLimitError(minInterval)))
There was a problem hiding this comment.
Actually it was inline in the beginning, but I've decided that the code is quite unreadable :)
IMHO this will not affect performance and the compiler will inline it anyway because it is used once, immediately after creation. Maybe it would be better to construct a kind of builder for responses instead of serializable Tuples. WDYT?
|
Just a minor comment, Maybe you can create the task mentioned. So then we can continue working with improvements. |
Description
Twitter-collections used for
LRUcache for Scala 2.13 is unavailable.Had to replace this
LRUby something with similar functionalityProposed Solution
The simplest possible
LRUis built onLinkedHashMapBoilerplate code is replaced by
Directive0implementationFurther improvement steps offered for JsonRPC server