YUKI Piro Hiroshi
null+****@clear*****
Fri Oct 17 23:51:51 JST 2014
YUKI "Piro" Hiroshi 2014-10-17 23:51:51 +0900 (Fri, 17 Oct 2014) New Revision: 2a38aca0a5a37b71bce34bf217e75252debf87fd https://github.com/droonga/express-droonga/commit/2a38aca0a5a37b71bce34bf217e75252debf87fd Message: Export ConnectionPool's nextIndex and hostNames Modified files: lib/droonga-protocol/connection-pool.js Modified: lib/droonga-protocol/connection-pool.js (+10 -10) =================================================================== --- lib/droonga-protocol/connection-pool.js 2014-10-17 23:48:46 +0900 (0773590) +++ lib/droonga-protocol/connection-pool.js 2014-10-17 23:51:51 +0900 (706093e) @@ -34,9 +34,9 @@ function ConnectionPool(params) { return true; } }); - this._params.hostNames = Object.keys(uniqueHostNames); + this.hostNames = this._params.hostNames = Object.keys(uniqueHostNames); - if (this._params.hostNames.length == 0) + if (this.hostNames.length == 0) throw new Error('ConnectionPool: you must give one or more host name(s)!'); this._connections = {}; @@ -45,7 +45,7 @@ function ConnectionPool(params) { ConnectionPool.prototype = { _instantiate: function() { - this._params.hostNames.forEach(function(hostName) { + this.hostNames.forEach(function(hostName) { if (this._connections[hostName]) return; @@ -59,28 +59,28 @@ ConnectionPool.prototype = { }); }, this); - this._nextIndex = Math.floor(Math.random() * this._params.hostNames.length); + this.nextIndex = Math.floor(Math.random() * this.hostNames.length); }, get: function() { - var hostName = this._params.hostNames[this._nextIndex]; + var hostName = this.hostNames[this.nextIndex]; - this._nextIndex++; - if (this._nextIndex == this._params.hostNames.length) - this._nextIndex = 0; + this.nextIndex++; + if (this.nextIndex == this.hostNames.length) + this.nextIndex = 0; return this._connections[hostName]; }, closeAll: function() { - this._params.hostNames.forEach(function(hostName) { + this.hostNames.forEach(function(hostName) { var connection = this._connections[hostName]; connection.close(); }, this); }, get count() { - return this._params.hostNames.length; + return this.hostNames.length; } }; -------------- next part -------------- HTML����������������������������...Download