Skip to content

Commit

Permalink
Address Ben's PR feedback; better name for fanout callback
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Nov 25, 2015
1 parent ed088c3 commit eb77144
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/gossip/damper.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ Damper.prototype.hasStarted = function hasStarted() {
return !!this.dampTimer;
};

// This function starts what is called "the damp-req subprotocol," which is a
// fancy name for fanning-out damp-req requests to a random collection of other
// members. The damp-req asks for the damp scores of members that were previously
// added to the internal flappers collection of this Damper module.
//
// initiateSubprotocol() is called periodically by the background damp timer when
// "flappers" have been added. If no flappers exist or all flappers have been removed,
// then the damp timer will be canceled and the subprotocol will not be initiated.
Damper.prototype.initiateSubprotocol = function initiateSubprotocol(callback) {
var self = this;
var config = this.ringpop.config;
Expand All @@ -268,11 +276,6 @@ Damper.prototype.initiateSubprotocol = function initiateSubprotocol(callback) {
return;
}

// You may think that a check to verify that flappers actually
// exist before firing off the fanout is necessary. I know I did.
// But in fact, the subprotocol will only ever be initiated when
// there are known flappers. Otherwise the damp timer would never
// have been scheduled.
var flapperAddrs = this._getFlapperAddrs();
this.logger.info('ringpop damper started', {
local: this.ringpop.whoami(),
Expand Down Expand Up @@ -303,9 +306,9 @@ Damper.prototype.initiateSubprotocol = function initiateSubprotocol(callback) {
return;
}

this._fanoutDampReqs(flapperAddrs, dampReqMembers, rVal, onDampReqs);
this._fanoutDampReqs(flapperAddrs, dampReqMembers, rVal, onFanout);

function onDampReqs(err, res) {
function onFanout(err, res) {
if (err) {
self.ringpop.stat('increment', 'damper.damp-req.error');
self.logger.warn('ringpop damper errored out', {
Expand Down

0 comments on commit eb77144

Please sign in to comment.