labstack / echox

Echo cookbook and website
https://echo.labstack.com
MIT License
409 stars 284 forks source link

Improve docs about Rate Limiter Middleware #287

Closed yagikota closed 1 year ago

yagikota commented 1 year ago

The current document is a little bit difficult to understand the usage of middleware.NewRateLimiterMemoryStore() when its argument is float . So, I added supplemental explanation.


Why is RateLimiterMemoryStoreConfig.Rate type of rate.Limit (float64)? Are there any case when we use float rate limit?

aldas commented 1 year ago

Are there any case when we use float rate limit?

I can only guess what Go-folks thought when they used float (https://pkg.go.dev/golang.org/x/time/rate#Limit). It is probably when you want to have requirements like events(requests) per minute/hour/day etc. limit of 11 events per minute normalized to events per second is 5.45... but yet again forcing these check per second would not make sense. Probably backwards compatibility sake or something

TBH: I do not know :)