volos-quota-common
Advanced tools
Comparing version 0.9.0 to 0.9.2
@@ -56,2 +56,4 @@ /**************************************************************************** | ||
// options.consistency (string) A hint to some SPIs about how to distribute quota around | ||
// options.bufferSize (Number) optional, use a memory buffer up to bufferSize to hold quota elements | ||
// options.bufferTimeout (Number) optional, flush the buffer every Number ms (default: 300) | ||
@@ -64,2 +66,3 @@ function Quota(Spi, o) { | ||
options.rollingWindow = o.rollingWindow || false; | ||
options.bufferSize = checkNumber(o.bufferSize, 'bufferSize') || 0; | ||
@@ -91,4 +94,15 @@ if (!options.timeUnit in TimeUnits) { | ||
if (options.bufferSize > 0) { | ||
options.bufferTimeout = checkNumber(o.bufferTimeout, 'bufferTimeout') || 300; | ||
} | ||
this.options = options; | ||
this.quota = new Spi(options); | ||
var spi = new Spi(options); | ||
if (options.bufferSize > 0) { | ||
var Buffer = require('./memory_buffer'); | ||
var buffer = Buffer.create(spi, options); | ||
this.quota = buffer; | ||
} else { | ||
this.quota = spi; | ||
} | ||
} | ||
@@ -100,5 +114,7 @@ module.exports = Quota; | ||
// options.allow (Number) default = whatever was set in policy setup, and this allows override | ||
// cb is invoked with first parameter error, second whether it was allowed, third stats on the quota | ||
// cb is invoked with first parameter error, second with stats on the quota | ||
// stats.allowed = setting of "allow" | ||
// stats.used = current value | ||
// stats.isAllowed = true if allowed | ||
// stats.expiryTime = end time (ms) for this window | ||
@@ -121,1 +137,11 @@ Quota.prototype.apply = function(o, cb) { | ||
}; | ||
Quota.prototype.expressMiddleware = function(options) { | ||
var mw = require('./quota-express'); | ||
return new mw(this, options); | ||
}; | ||
Quota.prototype.argoMiddleware = function(options) { | ||
var mw = require('./quota-argo'); | ||
return new mw(this, options); | ||
}; |
{ | ||
"name": "volos-quota-common", | ||
"version": "0.9.0", | ||
"version": "0.9.2", | ||
"main": "lib/quota.js", | ||
@@ -8,11 +8,12 @@ "license": "MIT", | ||
"homepage": "https://github.com/apigee/volos", | ||
"keywords": ["quota", "memory"], | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
}, | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "https://github.com/apigee/volos.git" | ||
"keywords": [ | ||
"quota", | ||
"memory" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/apigee/volos.git" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23489
6
507
6