volos-quota-common
Advanced tools
Comparing version 0.11.7 to 0.11.8
@@ -45,2 +45,6 @@ /**************************************************************************** | ||
function MemoryBuffer(spi, options) { | ||
if ( options.debug && typeof options.debug === "function") { | ||
debug = options.debug; | ||
} | ||
debug('Creating MemoryBuffer, timeInterval: %d, bufferTimeout: %d', options.timeInterval, options.bufferTimeout); | ||
this.spi = spi; | ||
@@ -89,2 +93,3 @@ this.options = options; | ||
this.buckets[options.identifier] = bucket; | ||
debug('current buckets:', Object.keys(this.buckets)); | ||
} | ||
@@ -109,2 +114,3 @@ bucket.apply(now, options, cb); | ||
if (now > b.expires) { | ||
debug('Bucket: %s expired at: %s in bucketTimer, deleting now.',b.options.identifier,new Date(b.expires).toISOString()); | ||
delete self.buckets.b; | ||
@@ -162,2 +168,3 @@ } | ||
if (time > this.expires) { | ||
debug('Bucket expired at: %s',new Date(this.expires).toISOString()); | ||
this.reset(now); // Quota bucket has expired. The timer also runs but only periodically | ||
@@ -171,2 +178,3 @@ } | ||
var count = this.count + this.remoteCount; | ||
debug('Bucket:%s applying check,count: %d, allow: %d',this.options.identifier, count, allow); | ||
if (!this.expiryTime) { this.calculateExpiration(); } | ||
@@ -226,5 +234,8 @@ var result = { | ||
if (!self.expires) { self.calculateExpiration(); } | ||
debug('Bucket state after flushing: %j ', { | ||
remoteCount: self.remoteCount, count: self.count, | ||
expires: new Date(self.expires).toISOString() | ||
}); | ||
if (cb) { cb(); } | ||
}); | ||
}; |
@@ -33,3 +33,5 @@ /**************************************************************************** | ||
} | ||
if ( quota.options.debug && typeof quota.options.debug === "function") { | ||
debug = quota.options.debug; | ||
} | ||
this.quota = quota; | ||
@@ -36,0 +38,0 @@ this.options = options || {}; |
{ | ||
"name": "volos-quota-common", | ||
"version": "0.11.6", | ||
"version": "0.11.8", | ||
"lockfileVersion": 1, | ||
@@ -5,0 +5,0 @@ "requires": true, |
{ | ||
"name": "volos-quota-common", | ||
"version": "0.11.7", | ||
"version": "0.11.8", | ||
"main": "lib/quota.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
535
29180
7