Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

changefeed

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

changefeed - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

28

lib/listener.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc