What's Changed
[BREAKING CHANGES]
-
Require
pointsanddurationoptions by @animir in #354No default values are set for
pointsanddurationoptions starting from v10. Negativepointswill not be replaced by default points value4.
Validation rules apply.Error is thrown during limiter creation if points or duration is invalid:
-
pointsmust be number.Any limiter accepts negative
pointsas valid option starting from v10. If you migrate from older version, be careful: If in your codepointsoption is set to negative value and that works for your project now then you should review the logic in your project. After update to version 10, negativepointsvalue will not be replaced by4by default as it was prior to version 10.When your limiter has negative or zero points
consumemethod call is always rejected since there is always not enough points to consume. You can setpointsto negative and play withrewardandconsumecalls, that could be useful sometimes. -
durationmust be non-negative number>= 0. Error is thrown during limiter creation ifdurationoption has invalid value.
Requiring
pointsanddurationseems logical for security package. We don't want our apps working not as we expect even if there is no security threat. This update removes uncertaincy about negative duration and zero points. -
[OTHER UPDATES]
-
Faster memory limiter and block mechanism by @animir in #355
Internal memory storage implementation refactored for Map with timestamps instead of Date objects.
Memory limiter is faster on 10-15% now on high traffic with diverse keys. Tests show performance improvement from
2569948 ops/secto2885688 ops/secon my laptop.
Full Changelog: v9.1.1...v10.0.0