feat(data-structures/unstable): add RollingCounter#7028
feat(data-structures/unstable): add RollingCounter#7028tomas-zijdemans wants to merge 5 commits intodenoland:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7028 +/- ##
=======================================
Coverage 93.83% 93.84%
=======================================
Files 624 625 +1
Lines 49629 49693 +64
Branches 8721 8733 +12
=======================================
+ Hits 46571 46635 +64
Misses 2478 2478
Partials 580 580 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Is it common to call this data structure Sliding Window Counter? Is there any prior example library? I research a bit about rate limiting algorithms, but this data structure seems more similar to one for sliding window log to me (sliding window counter seems using only 2 fixed windows and combining them with weighted interpolation) |
I agree. I was looking at a Go package. Renaming to So usage could look like: |
This data structure tracks counts across a fixed number of segments using a ring buffer. The caller controls when the window advances by calling rotate(), making it useful for rate limiting (I'm working on a new module for that),
circuit breaker++