changefeed
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -126,29 +126,50 @@ /* | ||
// Handles bucket initilization and backoff on failure | ||
function _bucketInit() { | ||
var error; | ||
morayClient.getBucket(self.morayBucket.name, function _gb(err) { | ||
if (err && err.name === 'BucketNotFoundError') { | ||
var name = self.morayBucket.name; | ||
var config = self.morayBucket.config; | ||
morayClient.createBucket(name, config, function _cb(err2) { | ||
log.info({ n: name, c: config }, 'cf: creating bucket'); | ||
if (err2) { | ||
log.error({ cErr: err2 }, 'cf: Bucket not created'); | ||
expBackoff.backoff(); | ||
} else { | ||
log.info('cf: Bucket successfully setup'); | ||
self.emit('moray-ready'); | ||
expBackoff.reset(); | ||
} | ||
}); | ||
} else if (err) { | ||
log.error({ cErr: err }, 'cf: Bucket was not loaded'); | ||
expBackoff.backoff(); | ||
} else { | ||
log.info('cf: Bucket successfully setup'); | ||
self.emit('moray-ready'); | ||
expBackoff.reset(); | ||
} | ||
}); | ||
} | ||
morayClient.on('error', function _morayError(err) { | ||
log.error(err, 'moray client error'); | ||
log.error(err, 'cf: moray client error'); | ||
}); | ||
expBackoff.on('backoff', function _backoff(number, delay) { | ||
log.warn('Backing off -- retry count: %s delay: %s', number, delay); | ||
log.warn('cf: Backoff -- retry count: %s delay: %s', number, delay); | ||
}); | ||
expBackoff.on('ready', function _ready(number, delay) { | ||
// Auto setup the change feed moray bucket | ||
self._setupBucket(function _bucketSetupError(err) { | ||
if (err) { | ||
log.error({ err: err }, 'Bucket was not loaded'); | ||
} else { | ||
log.info('Bucket successfully loaded'); | ||
self.emit('moray-ready'); | ||
expBackoff.reset(); | ||
} | ||
}); | ||
log.info('cf: Backoff ready -- retry count: %s:', number); | ||
_bucketInit(); | ||
}); | ||
expBackoff.on('fail', function _fail() { | ||
log.error('backoff failed'); | ||
log.error('cf: backoff failed'); | ||
self.emit('moray-fail'); | ||
}); | ||
expBackoff.backoff(); | ||
_bucketInit(); | ||
}); | ||
@@ -344,7 +365,2 @@ | ||
Publisher.prototype._createBucket = function _createBucket(cb) { | ||
var bucket = this.morayBucket; | ||
this.morayClient.createBucket(bucket.name, bucket.config, cb); | ||
}; | ||
Publisher.prototype._getBucket = function _getBucket(cb) { | ||
@@ -416,17 +432,2 @@ this.morayClient.getBucket(this.morayBucket.name, cb); | ||
Publisher.prototype._setupBucket = function _setupBucket(cb) { | ||
var self = this; | ||
self._getBucket(function _getBucketError(err) { | ||
if (err) { | ||
if (err.name === 'BucketNotFoundError') { | ||
self._createBucket(cb); | ||
} else { | ||
return cb(err); | ||
} | ||
} | ||
return cb(err); | ||
}); | ||
}; | ||
module.exports = Publisher; |
{ | ||
"name": "changefeed", | ||
"description": "Change Feed Modules", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"author": "Joyent (joyent.com)", | ||
@@ -6,0 +6,0 @@ "private": false, |
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
48448
628