Closed JelteF closed 6 years ago
This is a good change, but it would definitely change the default behavior of the lib (see the failed unit test) and require a major version bump. I would recommend either adding an additional parameter to the TokenBucket constructor, something like startFull
or initialContent
, or just set myBucket.content = myBucket. bucketSize;
after instantiating.
I'm going to close this PR for now; please resubmit if you want to go for the first approach.
I ran into issues where after creating a bucket on demand for new customers the customer would get rate limited right away. This was caused by the fact that a new bucket is empty. This PR changes the code so a new bucket will start full.