WIP: initial prototype
- Updated ConnectionPool internals - Added ConnectionPool.update api - Experimental: return http response in transform
This commit is contained in:
@ -34,6 +34,7 @@ class Transport {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: should be able to send a stream of json data
|
||||
request (params, callback) {
|
||||
callback = once(callback)
|
||||
const result = { body: null, statusCode: null, headers: null, warnings: null }
|
||||
@ -115,6 +116,13 @@ class Transport {
|
||||
result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/)
|
||||
}
|
||||
|
||||
// TODO: expose `asStream` option for returning the
|
||||
// body already parsed?
|
||||
if (params.asHttpResponse === true) {
|
||||
callback(null, response)
|
||||
return
|
||||
}
|
||||
|
||||
var payload = ''
|
||||
// collect the payload
|
||||
response.setEncoding('utf8')
|
||||
@ -215,9 +223,7 @@ class Transport {
|
||||
|
||||
debug('Sniffing ended successfully', body)
|
||||
const hosts = this.connectionPool.nodesToHost(body.nodes)
|
||||
this.connectionPool
|
||||
.empty()
|
||||
.addConnection(hosts)
|
||||
this.connectionPool.update(hosts)
|
||||
|
||||
callback(null, hosts)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user