Continuing with the previous experiment using debounce to rollup multiple messages, the problem with debounce is that the window is static. I want an abstraction that supports a dynamic period.
For example, the window could start at 1s, but when there are a ton of messages or when we know it’s a high volume account, the window should increase proportionaly. So I need a different abstraction.
In this experiment, I change the code to use a “Leaky Bucket”. It’s basically a queue (array) that drains periodically.
I will look making the drain interval dynamic, based on the data rate.