The getAttempts method returns amount of used attempts.
The getExpiration method should return the expiration as Date.
This method is optional, if defined rate limiter data will be cleaned up when expired.
If not defined the rate limiter data will be stored forever.
The updateMetrics method updates the metrics when an attempt occurs.
Each request inside a fixed time increases a counter. Once the counter reaches the maximum allowed number, all further attempts are rejected.
Pro:
Con:
A burst of attempts near the boundary of a window can result in a very high request rate because two windows will be filled with attempts quickly.
IMPORT_PATH:
"@daiso-tech/core/rate-limiter/policies"