Skip to content

Commit

Permalink
Throttle to update host names from member-change events
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Nov 5, 2014
1 parent 7efaed3 commit c9b9b77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/droonga-protocol/connection-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ ConnectionPool.prototype = {
this._logger.error('Failed to start watching of changes in the cluster.');
this._logger.error(error);
});
this._serf.on('member-change', this.updateHostNamesFromCluster.bind(this));
this._serf.on('member-change', (function() {
if (this._updateHostNamesTimer)
return;
this._updateHostNamesTimer = setTimeout((function() {
this._updateHostNamesTimer = null;
this.updateHostNamesFromCluster();
}).bind(this), 500);
}).bind(this));
this._watching = true;
},

Expand Down

0 comments on commit c9b9b77

Please sign in to comment.