changefeed
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -13,3 +13,2 @@ /* | ||
var mod_backoff = require('backoff'); | ||
var mod_bunyan = require('bunyan'); | ||
var mod_restify = require('restify-clients'); | ||
@@ -23,3 +22,2 @@ var mod_util = require('util'); | ||
var pollInterval = 27817; | ||
var attempt = 0; | ||
var HTTP_MODIFIER = 'http://%s'; | ||
@@ -88,2 +86,3 @@ var PORT_MODIFIER = ':%s'; | ||
self.closed = false; | ||
self.initBootstrap = false; | ||
@@ -113,3 +112,4 @@ } | ||
url: self.url, | ||
retry: self.backoff_opts | ||
agent: false, | ||
retry: false | ||
}; | ||
@@ -216,3 +216,10 @@ | ||
client.get(ROOT_PATH, function _test(err, res, socket, head) { | ||
if (err) { | ||
log.warn(err, 'cf: _test: error'); | ||
expBackoff.backoff(); | ||
return; | ||
} | ||
log.debug('cf: _test'); | ||
res.on('result', function _result(err2, res2) { | ||
@@ -231,9 +238,4 @@ log.debug('cf: _result'); | ||
client.on('attempt', function _attempt() { | ||
attempt = attempt + 1; | ||
log.warn('cf: restify backoff attempt: %s', attempt); | ||
}); | ||
expBackoff.on('backoff', function _backoff(number, delay) { | ||
log.warn('cf: Backoff retry count: %s delay: %s', number, delay); | ||
log.debug('cf: Backoff retry count: %s delay: %s', number, delay); | ||
}); | ||
@@ -245,2 +247,8 @@ expBackoff.on('fail', function _fail() { | ||
expBackoff.on('ready', function _ready(number, delay) { | ||
if (self.closed) { | ||
log.info('cf: _ready: listener closed, resetting'); | ||
expBackoff.reset(); | ||
return; | ||
} | ||
log.info('cf: _ready'); | ||
@@ -268,4 +276,6 @@ _init(); | ||
} | ||
this.closed = true; | ||
}; | ||
module.exports = Listener; |
@@ -8,3 +8,3 @@ /* | ||
/* | ||
* Copyright (c) 2017, Joyent, Inc. | ||
* Copyright (c) 2018, Joyent, Inc. | ||
*/ | ||
@@ -15,3 +15,2 @@ | ||
var mod_backoff = require('backoff'); | ||
var mod_bunyan = require('bunyan'); | ||
var mod_libuuid = require('libuuid'); | ||
@@ -21,2 +20,3 @@ var mod_moray = require('moray'); | ||
var mod_vasync = require('vasync'); | ||
var VError = require('verror'); | ||
var Watershed = require('watershed').Watershed; | ||
@@ -28,2 +28,23 @@ | ||
function assertPublisherOptions(options) { | ||
mod_assert.object(options, 'options'); | ||
mod_assert.object(options.log, 'options.log'); | ||
mod_assert.object(options.moray, 'options.moray'); | ||
mod_assert.string(options.moray.bucketName, 'options.moray.bucketName'); | ||
mod_assert.optionalObject(options.backoff, 'options.backoff'); | ||
mod_assert.optionalObject(options.moray.client, 'options.moray.client'); | ||
mod_assert.optionalObject(options.restifyServer, 'options.restifyServer'); | ||
if (options.moray.client === undefined || options.moray.client === null) { | ||
mod_assert.string(options.moray.host, 'options.moray.host'); | ||
mod_assert.number(options.moray.port, 'options.moray.port'); | ||
} else { | ||
mod_assert.equal(options.moray.host, undefined, 'options.moray.host'); | ||
mod_assert.equal(options.moray.port, undefined, 'options.moray.port'); | ||
} | ||
} | ||
function isBucketNotFoundError(err) { | ||
return err && VError.hasCauseWithName(err, 'BucketNotFoundError'); | ||
} | ||
/* | ||
@@ -61,2 +82,3 @@ * Publisher module constructor that takes an options object. | ||
function Publisher(options) { | ||
assertPublisherOptions(options); | ||
var self = this; | ||
@@ -87,8 +109,2 @@ self.pollInterval = null; | ||
var morayOptions = options.moray; | ||
self.morayHost = morayOptions.host; | ||
self.morayResovlers = morayOptions.resolvers; | ||
self.morayTimeout = morayOptions.timeout; | ||
self.morayMinTimeout = morayOptions.minTimeout; | ||
self.morayMaxTimeout = morayOptions.maxTimeout; | ||
self.morayPort = morayOptions.port; | ||
self.morayBucket = { | ||
@@ -105,17 +121,18 @@ name: morayOptions.bucketName, | ||
var log = this.log = options.log; | ||
var morayClient = this.morayClient = mod_moray.createClient({ | ||
dns: this.morayResolvers, | ||
connectTimeout: this.morayTimeout || 200, | ||
log: this.log, | ||
host: this.morayHost, | ||
port: this.morayPort, | ||
reconnect: false, | ||
retry: { | ||
retries: Infinity, | ||
minTimeout: this.morayMinTimeout || 1000, | ||
maxTimeout: this.morayMaxTimeout || 16000 | ||
} | ||
}); | ||
if (morayOptions.client) { | ||
self.morayClient = morayOptions.client; | ||
self.morayClientNeedsClose = false; | ||
setImmediate(onMorayConnect); | ||
} else { | ||
self.morayClient = mod_moray.createClient({ | ||
log: options.log, | ||
host: morayOptions.host, | ||
port: morayOptions.port | ||
}); | ||
self.morayClient.on('connect', onMorayConnect); | ||
self.morayClientNeedsClose = true; | ||
} | ||
var log = self.log = options.log; | ||
var morayClient = self.morayClient; | ||
var expBackoff = mod_backoff.exponential({ | ||
@@ -128,3 +145,3 @@ initialDelay: self.minTimeout, | ||
morayClient.on('connect', function _morayConnect() { | ||
function onMorayConnect() { | ||
log.trace('cf: _morayConnect: started'); | ||
@@ -137,3 +154,3 @@ log.info({ moray: morayClient.toString() }, 'cf: moray: connected'); | ||
morayClient.getBucket(self.morayBucket.name, function _gb(err) { | ||
if (err && err.name === 'BucketNotFoundError') { | ||
if (isBucketNotFoundError(err)) { | ||
var name = self.morayBucket.name; | ||
@@ -182,3 +199,3 @@ var config = self.morayBucket.config; | ||
_bucketInit(); | ||
}); | ||
} | ||
@@ -285,3 +302,5 @@ if (options && options.restifyServer) { | ||
clearInterval(self.gcPollInterval); | ||
self.morayClient.close(); | ||
if (self.morayClientNeedsClose) { | ||
self.morayClient.close(); | ||
} | ||
}; | ||
@@ -310,3 +329,3 @@ | ||
req.on('error', function _reqErr(err) { | ||
log.warn(err); | ||
log.warn(err, 'cf: _poll: error'); | ||
}); | ||
@@ -313,0 +332,0 @@ |
{ | ||
"name": "changefeed", | ||
"description": "Change Feed Modules", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"author": "Joyent (joyent.com)", | ||
@@ -15,14 +15,15 @@ "repository": { | ||
"backoff": "2.4.1", | ||
"bunyan": "1.5.1", | ||
"jsprim": "1.4.0", | ||
"libuuid": "0.2.1", | ||
"moray": "git+ssh://git@github.com:joyent/node-moray.git#fd5781bc25a9", | ||
"moray": "3.4.2", | ||
"posix-getopt": "1.2.0", | ||
"restify-clients": "1.1.1", | ||
"restify-clients": "1.5.3", | ||
"sprintf-js": "1.0.3", | ||
"vasync": "1.6.3", | ||
"verror": "1.9.0", | ||
"vstream": "0.1.0", | ||
"watershed": "0.3.3" | ||
"watershed": "0.4.0" | ||
}, | ||
"devDependencies": { | ||
"bunyan": "1.8.12", | ||
"tape": "4.2.2", | ||
@@ -29,0 +30,0 @@ "restify": "4.0.3" |
@@ -8,3 +8,3 @@ <!-- | ||
<!-- | ||
Copyright (c) 2017, Joyent, Inc. | ||
Copyright (c) 2018, Joyent, Inc. | ||
--> | ||
@@ -58,3 +58,3 @@ | ||
``` | ||
```javascript | ||
var mod_bunyan = require('bunyan'); | ||
@@ -96,3 +96,3 @@ var mod_changefeed = require('changefeed'); | ||
``` | ||
```javascript | ||
var mod_bunyan = require('bunyan'); | ||
@@ -122,2 +122,16 @@ var mod_changefeed = require('changefeed'); | ||
var listener = mod_changefeed.createListener(options); | ||
listener.on('bootstrap', function (resource) { | ||
// do bootstrap, then pipe to a change handler. | ||
doBootstrap(resource); | ||
listener.pipe(change_handler); | ||
}); | ||
listener.on('error', function (err) { | ||
console.log(err); | ||
}); | ||
listener.on('connection-end', function () { | ||
listener.unpipe(change_handler); | ||
}); | ||
``` | ||
@@ -124,0 +138,0 @@ |
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
51783
675
147
0
0
3
+ Addedverror@1.9.0
+ Addedabort-controller@3.0.0(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedare-we-there-yet@1.1.7(transitive)
+ Addedartedi@2.0.3(transitive)
+ Addedasn1@0.1.11(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbindings@1.2.1(transitive)
+ Addedbl@1.2.3(transitive)
+ Addedbloomfilter@0.0.16(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedbuffer-alloc@1.2.0(transitive)
+ Addedbuffer-alloc-unsafe@1.1.0(transitive)
+ Addedbuffer-fill@1.0.0(transitive)
+ Addedbunyan@1.8.15(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedcmdutil@1.1.1(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addedcrc@3.4.4(transitive)
+ Addedcsv@0.4.6(transitive)
+ Addedcsv-generate@0.0.6(transitive)
+ Addedcsv-parse@1.3.3(transitive)
+ Addedcsv-stringify@0.0.8(transitive)
+ Addedctype@0.5.3(transitive)
+ Addedcueball@2.10.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addeddetect-node@2.1.0(transitive)
+ Addeddtrace-provider@0.8.8(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedescape-regexp-component@1.0.2(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedexpand-template@1.1.1(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast@2.8.2(transitive)
+ Addedfast-safe-stringify@1.2.3(transitive)
+ Addedformidable@1.2.6(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedgauge@2.7.4(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhandle-thing@1.2.5(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhpack.js@2.1.6(transitive)
+ Addedhttp-deceiver@1.2.7(transitive)
+ Addedhttp-signature@0.11.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedini@1.3.8(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjsprim@2.0.2(transitive)
+ Addedkang@1.3.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedlstream@0.0.4(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmicrotime@2.1.6(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedmname@1.5.1(transitive)
+ Addedmname-client@0.5.1(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedmooremachine@2.3.0(transitive)
+ Addedmoray@3.4.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednan@2.6.2(transitive)
+ Addednegotiator@0.6.4(transitive)
+ Addednode-abi@2.30.1(transitive)
+ Addednoop-logger@0.1.1(transitive)
+ Addednpmlog@4.1.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobuf@1.1.2(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedprebuild-install@2.5.3(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedprogbar@0.1.0(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedpump@1.0.32.0.1(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@2.3.84.6.0(transitive)
+ Addedrestify@4.3.3(transitive)
+ Addedrestify-clients@1.5.3(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedselect-hose@2.0.0(transitive)
+ Addedsemver@4.3.6(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@2.8.2(transitive)
+ Addedspdy@3.4.7(transitive)
+ Addedspdy-transport@2.1.1(transitive)
+ Addedsprintf@0.1.5(transitive)
+ Addedstream-transform@0.1.2(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@1.1.11.3.0(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedstrsplit@1.0.0(transitive)
+ Addedtar-fs@1.16.3(transitive)
+ Addedtar-stream@1.6.2(transitive)
+ Addedto-buffer@1.1.1(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedvasync@1.6.42.2.1(transitive)
+ Addedverror@1.10.01.9.0(transitive)
+ Addedwatershed@0.4.0(transitive)
+ Addedwbuf@1.7.3(transitive)
+ Addedwhich-pm-runs@1.1.0(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedbunyan@1.5.1
- Removedbunyan@1.5.1(transitive)
- Removeddtrace-provider@0.6.0(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedrestify-clients@1.1.1(transitive)
- Removedwatershed@0.3.3(transitive)
Updatedmoray@3.4.2
Updatedrestify-clients@1.5.3
Updatedwatershed@0.4.0