couchdb-stat-collector
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -85,2 +85,7 @@ #!/usr/bin/env node | ||
}, | ||
'nice-timeout': { | ||
alias: 'n', | ||
description: 'Timeout in milliseconds to wait between each task. Helpful to prevent hosing the cluster.', | ||
type: 'number' | ||
}, | ||
verbose: { | ||
@@ -117,2 +122,3 @@ alias: 'v', | ||
const negativeFilterLimit = argv['negative-filter-limit'] | ||
const niceTimeout = argv['nice-timeout'] | ||
const { resume, service } = argv | ||
@@ -127,2 +133,3 @@ const { href } = couchUrl | ||
negativeFilterLimit, | ||
niceTimeout, | ||
isResume: resume, | ||
@@ -129,0 +136,0 @@ service, |
@@ -28,2 +28,3 @@ const fs = require('fs') | ||
negativeFilterLimit, | ||
niceTimeout, | ||
outDir, | ||
@@ -72,3 +73,4 @@ save, | ||
negativeFilterDbs, | ||
negativeFilterLimit | ||
negativeFilterLimit, | ||
niceTimeout | ||
}) | ||
@@ -75,0 +77,0 @@ |
@@ -25,3 +25,3 @@ const assert = require('assert') | ||
}, { | ||
argv, couchUrl, instanceName, inProgressDir, filterDbs, filterLimit, negativeFilterDbs, negativeFilterLimit | ||
argv, couchUrl, instanceName, inProgressDir, filterDbs, filterLimit, negativeFilterDbs, negativeFilterLimit, niceTimeout | ||
}) { | ||
@@ -31,3 +31,3 @@ assert.strictEqual(typeof couchUrl, 'string', `"couchUrl" is a required options parameter and must be a string.`) | ||
assert.strictEqual(typeof route, 'string', `"route" is a required task parameter and must be a string.`) | ||
this._options = { couchUrl, instanceName, filterDbs, filterLimit, negativeFilterDbs, negativeFilterLimit, argv: argv || {} } | ||
this._options = { couchUrl, instanceName, filterDbs, filterLimit, negativeFilterDbs, negativeFilterLimit, niceTimeout, argv: argv || {} } | ||
// format task, set defaults | ||
@@ -45,2 +45,4 @@ const task = { after, mode, query, save, version } | ||
this._filePath = path.join(this._inProgressDir, this._fileName) | ||
// set nice timeout to keep from hosing clusters | ||
this._nice = niceTimeout | ||
} | ||
@@ -61,2 +63,7 @@ | ||
if (this._task.query) reqOpts.qs = this._task.query | ||
if (this._nice) { | ||
await new Promise((resolve) => { | ||
setTimeout(resolve, this._nice) | ||
}) | ||
} | ||
const { body } = await request(reqOpts) | ||
@@ -89,3 +96,3 @@ return body | ||
const { access, after, mode, name, save, version } = this._task | ||
const { argv, couchUrl, instanceName } = this._options | ||
const { argv } = this._options | ||
@@ -126,4 +133,3 @@ // check semver | ||
await Task.execute(afterTask, { | ||
couchUrl, | ||
instanceName, | ||
...this._options, | ||
argv: { ...argv, ...subArgv } | ||
@@ -134,4 +140,3 @@ }) | ||
await Task.execute(afterTask, { | ||
couchUrl, | ||
instanceName, | ||
...this._options, | ||
argv: { ...argv, ...newArgv } | ||
@@ -138,0 +143,0 @@ }) |
@@ -53,3 +53,2 @@ const fs = require('fs') | ||
if (error || (response.statusCode >= 400)) { | ||
console.trace(response && (response.statusCode === 413)) | ||
if (response && (response.statusCode === 413)) { | ||
@@ -56,0 +55,0 @@ error = new Error('payload too large') |
{ | ||
"name": "couchdb-stat-collector", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "A stat collection tool for CouchDB.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,2 +51,15 @@ /* global afterEach, before, beforeEach, describe, it */ | ||
it('should respect courtesy timeouts', async function () { | ||
const niceTimeout = 250 | ||
const start = Date.now() | ||
nock(couchUrl) | ||
.get('/') | ||
.reply(200, { couchdb: 'Welcome' }) | ||
await Task.execute({ | ||
route: '' | ||
}, { niceTimeout, ...this.options }) | ||
const end = Date.now() | ||
assert(end - start > niceTimeout) | ||
}) | ||
it('should run sub-tasks', async function () { | ||
@@ -53,0 +66,0 @@ nock(couchUrl) |
@@ -50,3 +50,3 @@ /* global afterEach, describe, it */ | ||
it.only('should handle rejection due to large entity', async function () { | ||
it('should handle rejection due to large entity', async function () { | ||
this.timeout(0) | ||
@@ -53,0 +53,0 @@ const couch = nock(couchUrl) |
Sorry, the diff of this file is too big to display
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
209022
5717