WIP: initial prototype

- Added support for request timeout
- Improved deserializer
- Fixed minor bugs
- Fixed typos
This commit is contained in:
delvedor
2018-10-22 16:50:17 +02:00
parent 68cca6069b
commit cef4e2dfc1
4 changed files with 32 additions and 17 deletions

View File

@ -10,7 +10,8 @@ class ConnectionPool {
this.alive = []
this.dead = []
this.selector = opts.selector
this.sll = opts.sll
this._ssl = opts.ssl
this._agent = opts.agent
// the resurrect timeout is 60s
// we multiply it by 2 because the resurrect formula is
// `Math.pow(resurrectTimeout * 2, deadCount -1)`
@ -143,12 +144,17 @@ class ConnectionPool {
if (typeof opts === 'string') {
opts = this.urlToHost(opts)
}
Object.assign(opts, this.ssl)
if (opts.ssl == null) opts.ssl = this._ssl
if (opts.agent == null) opts.agent = this._agent
const connection = new Connection(opts)
debug('Adding a new connection', connection)
if (this.connections.has(connection.id)) {
throw new Error(`Connection with id '${connection.id} is already present`)
}
this.connections.set(connection.id, connection)
this.alive.push(connection.id)
return this
return connection
}
/**