@d-fischer/rate-limiter
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -39,3 +39,8 @@ "use strict"; | ||
queue.push(reqSpec); | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, waiting for a free bucket entry; queue size is ").concat(queue.length)); | ||
if (usedFromBucket + queue.length >= _this._bucketSize) { | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, waiting for ").concat(_this._paused ? 'the limiter to be unpaused' : 'a free bucket entry', "; queue size is ").concat(queue.length)); | ||
} | ||
else { | ||
_this._logger.info("Enqueueing request for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " because the rate limiter is paused; queue size is ").concat(queue.length)); | ||
} | ||
break; | ||
@@ -45,7 +50,14 @@ } | ||
reqSpec.resolve(null); | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, dropping request and returning null")); | ||
if (_this._paused) { | ||
_this._logger.info("Returning null for request for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " because the rate limiter is paused")); | ||
} | ||
else { | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, dropping request and returning null")); | ||
} | ||
break; | ||
} | ||
case 'throw': { | ||
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError("Request dropped because the rate limit for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached"))); | ||
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError("Request dropped because ".concat(_this._paused | ||
? 'the rate limiter is paused' | ||
: "the rate limit for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached")))); | ||
break; | ||
@@ -52,0 +64,0 @@ } |
@@ -35,3 +35,8 @@ "use strict"; | ||
_this._queue.push(reqSpec); | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, waiting for a free bucket entry; queue size is ").concat(_this._queue.length)); | ||
if (_this._usedFromBucket + _this._queue.length >= _this._bucketSize) { | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, waiting for ").concat(_this._paused ? 'the limiter to be unpaused' : 'a free bucket entry', "; queue size is ").concat(_this._queue.length)); | ||
} | ||
else { | ||
_this._logger.info("Enqueueing request because the rate limiter is paused; queue size is ".concat(_this._queue.length)); | ||
} | ||
break; | ||
@@ -42,6 +47,12 @@ } | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, dropping request and returning null")); | ||
if (_this._paused) { | ||
_this._logger.info('Returning null for request because the rate limiter is paused'); | ||
} | ||
else { | ||
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, dropping request and returning null")); | ||
} | ||
break; | ||
} | ||
case 'throw': { | ||
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError('Request dropped because the rate limit was reached')); | ||
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError("Request dropped because ".concat(_this._paused ? 'the rate limiter is paused' : 'the rate limit was reached'))); | ||
break; | ||
@@ -48,0 +59,0 @@ } |
{ | ||
"name": "@d-fischer/rate-limiter", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "Rate limit your requests.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202988
2717