Skip to content

Commit

Permalink
feat: support quit cluster gracefully. Close #315
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jun 25, 2016
1 parent 0ac7eef commit f2ef3a8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/cluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,27 @@ Cluster.prototype.disconnect = function (reconnect) {
this.connectionPool.reset([]);
};

/**
* Quit the cluster gracefully.
*
* @return {Promise}
* @public
*/
Cluster.prototype.quit = function (reconnect) {
this.setStatus('disconnecting');

if (!reconnect) {
this.manuallyClosing = true;
}
if (this.reconnectTimeout) {
clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null;
}
return this.nodes().map(function (node) {
return node.quit();
});
};

/**
* Get nodes with the specified role
*
Expand Down

0 comments on commit f2ef3a8

Please sign in to comment.