Karsten Schmidt<p><a href="https://mastodon.thi.ng/tags/ReleaseMonday" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ReleaseMonday</span></a> — One of the recent (already very useful!) new package additions to <a href="https://mastodon.thi.ng/tags/ThingUmbrella" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ThingUmbrella</span></a> is:</p><p><a href="https://thi.ng/leaky-bucket" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">thi.ng/leaky-bucket</span><span class="invisible"></span></a></p><p>Leaky buckets are commonly used in communication networks for rate limiting, traffic shaping and bandwidth control, but are equally useful in other domains requiring similar constraints.</p><p>A Leaky Bucket is a managed counter with an enforced maximum value (i.e. bucket capacity). The counter is incremented for each a new event to check if it can/should be processed. If the bucket capacity has already been reached, the bucket will report an overflow, which we can then handle accordingly (e.g. by dropping or queuing events). The bucket also has a configurable time interval at which the counter is decreasing (aka the "leaking" behavior) until it reaches zero again (i.e. until the bucket is empty). Altogether, this setup can be utilized to ensure both an average rate, whilst also supporting temporary bursting in a controlled fashion...</p><p>Related, I've also updated/simplified the rate limiter interceptor in <a href="https://thi.ng/server" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">thi.ng/server</span><span class="invisible"></span></a> to utilize this new package...</p><p><a href="https://mastodon.thi.ng/tags/ThingUmbrella" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ThingUmbrella</span></a> <a href="https://mastodon.thi.ng/tags/DataStructure" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>DataStructure</span></a> <a href="https://mastodon.thi.ng/tags/RateLimiting" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>RateLimiting</span></a> <a href="https://mastodon.thi.ng/tags/OpenSource" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>OpenSource</span></a> <a href="https://mastodon.thi.ng/tags/TypeScript" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>TypeScript</span></a> <a href="https://mastodon.thi.ng/tags/JavaScript" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>JavaScript</span></a></p>