message: Split reconnect logic to it's own function
  Use a QueuePool so we don't do all connection attempts at once.
diff: * and may be closed for a variety of reasons.
  */
  "use strict";
  -var stats = require("../config/stats");
  -var log = require("../logging").get("ClientPool");
  -var Promise = require("bluebird");
  +const stats = require("../config/stats");
  +const log = require("../logging").get("ClientPool");
  +const Promise = require("bluebird");
  +const QueuePool = require("../util/QueuePool");
  -const RECONNECT_TIME_MS = 1000;
  +const RECONNECT_CLIENT_QUEUE_SIZE = 20;
  function ClientPool(ircBridge) {
  this._ircBridge = ircBridge;
  @@ -35,6 +36,13 @@ function ClientPool(ircBridge) {
  this._virtualClientCounts = {
  // server_domain: number
  };
  + this._reconnectQueue = new QueuePool(
  + RECONNECT_CLIENT_QUEUE_SIZE,
  + (item) => {
  + log.info(`Reconnecting client. ${this._reconnectQueue.waitingItems} left.`);
  + return this._reconnectClient(item);
  + }
  + );
  }
  ClientPool.prototype.killAllClients = function() {
  @@ -276,8 +284,11 @@ ClientPool.prototype._onClientDisconnected = function(bridgedClient) {
  // remove ref to the disconnected client so it can be GC'd. If we don't do this,
  // the timeout below holds it in a closure, preventing it from being GC'd.
  bridgedClient = undefined;
  - setTimeout(function() {
  - cli.connect().then(function() {
  + this._reconnectQueue.enqueue(cli._id, {cli, chanList});
  +};
  +
  +ClientPool.prototype._reconnectClient = function({cli, chanList}) {
  + return cli.connect().then(() => {
  log.info(
  "<%s> Reconnected %s@%s", cli._id, cli.nick, cli.server.domain
  );
  @@ -287,14 +298,13 @@ ClientPool.prototype._onClientDisconnected = function(bridgedClient) {
  cli.joinChannel(c);
  });
  }
  - self._sendConnectionMetric(cli.server);
  + this._sendConnectionMetric(cli.server);
  }, function(e) {
  log.error(
  "<%s> Failed to reconnect %s@%s", cli._id, cli.nick, cli.server.domain
  );
  });
  - }, RECONNECT_TIME_MS);
  -};
  +}
  ClientPool.prototype._onNickChange = function(bridgedClient, oldNick, newNick) {
  this._virtualClients[bridgedClient.server.domain].nicks[oldNick] = undefined;
  