tokenbucket
Advanced tools
Comparing version
{ | ||
"name": "tokenbucket", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A flexible rate limiter using different variations of the Token Bucket algorithm, with hierarchy support, and optional persistence in Redis. Useful for limiting API requests, or other tasks that need to be throttled.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -48,7 +48,7 @@ [](https://david-dm.org/jesucarr/tokenbucket) | ||
| [options.tokensToAddPerInterval] | <code>Number</code> | <code>1</code> | Number of tokens to add to the bucket in one interval. | | ||
| [options.interval] | <code>Number</code> \| <code>String</code> | <code>1000</code> | The time passing between adding tokens, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. | | ||
| [options.interval] | <code>Number</code> | <code>String</code> | <code>1000</code> | The time passing between adding tokens, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. | | ||
| [options.lastFill] | <code>Number</code> | | The timestamp of the last time when tokens where added to the bucket (last interval). | | ||
| [options.tokensLeft] | <code>Number</code> | <code>size</code> | By default it will initialize full of tokens, but you can set here the number of tokens you want to initialize it with. | | ||
| [options.spread] | <code>Boolean</code> | <code>false</code> | By default it will wait the interval, and then add all the tokensToAddPerInterval at once. If you set this to true, it will insert fractions of tokens at any given time, spreading the token addition along the interval. | | ||
| [options.maxWait] | <code>Number</code> \| <code>String</code> | | The maximum time that we would wait for enough tokens to be added, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. If any of the parents in the hierarchy has `maxWait`, we will use the smallest value. | | ||
| [options.maxWait] | <code>Number</code> | <code>String</code> | | The maximum time that we would wait for enough tokens to be added, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. If any of the parents in the hierarchy has `maxWait`, we will use the smallest value. | | ||
| [options.redis] | <code>Object</code> | | Options object for Redis | | ||
@@ -220,7 +220,7 @@ | options.redis.bucketName | <code>String</code> | | The name of the bucket to reference it in Redis. Must be unique. | | ||
Contributions are welcome! | ||
Contributions are welcome! Pull requests should have 100% code coverage. | ||
## Credits | ||
Originally inspired by [limiter](https://github.com/jhurliman/node-rate-limiter) | ||
Originally inspired by [limiter](https://github.com/jhurliman/node-rate-limiter). | ||
@@ -231,3 +231,3 @@ ## License | ||
Copyright 2015 Jesús Carrera | ||
Copyright 2015 Jesús Carrera - [frontendmatters.com](http://frontendmatters.com) | ||
@@ -234,0 +234,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81900
-1.09%9
-10%