@@ -50,14 +50,14 @@ export default class Connection {
5050 * @constructor
5151 * @param {Channel } channel - channel with a 'write' function and a 'onmessage' callback property.
5252 * @param {ConnectionErrorHandler } errorHandler the error handler.
53- * @param {string } hostPort - the hostname and port to connect to.
53+ * @param {ServerAddress } address - the server address to connect to.
5454 * @param {Logger } log - the configured logger.
5555 * @param {boolean } disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
5656 */
57- constructor ( channel , errorHandler , hostPort , log , disableLosslessIntegers = false ) {
57+ constructor ( channel , errorHandler , address , log , disableLosslessIntegers = false ) {
5858 this . id = idGenerator ++ ;
59- this . hostPort = hostPort ;
60- this . server = { address : hostPort } ;
59+ this . address = address ;
60+ this . server = { address : address . asHostPort ( ) } ;
6161 this . creationTimestamp = Date . now ( ) ;
6262 this . _errorHandler = errorHandler ;
6363 this . _disableLosslessIntegers = disableLosslessIntegers ;
@@ -81,22 +81,21 @@ export default class Connection {
8181 this . _isBroken = false ;
8282
8383 if ( this . _log . isDebugEnabled ( ) ) {
84- this . _log . debug ( `${ this } created towards ${ hostPort } ` ) ;
84+ this . _log . debug ( `${ this } created towards ${ address } ` ) ;
8585 }
8686 }
8787
8888 /**
8989 * Crete new connection to the provided address. Returned connection is not connected.
90- * @param {string } url - the Bolt endpoint to connect to.
90+ * @param {ServerAddress } address - the Bolt endpoint to connect to.
9191 * @param {object } config - this driver configuration.
9292 * @param {ConnectionErrorHandler } errorHandler - the error handler for connection errors.
9393 * @param {Logger } log - configured logger.
9494 * @return {Connection } - new connection.
9595 */
96- static create ( url , config , errorHandler , log ) {
97- const parsedAddress = urlUtil . parseDatabaseUrl ( url ) ;
98- const channelConfig = new ChannelConfig ( parsedAddress , config , errorHandler . errorCode ( ) ) ;
99- return new Connection ( new Channel ( channelConfig ) , errorHandler , parsedAddress . hostAndPort , log , config . disableLosslessIntegers ) ;
96+ static create ( address , config , errorHandler , log ) {
97+ const channelConfig = new ChannelConfig ( address , config , errorHandler . errorCode ( ) ) ;
98+ return new Connection ( new Channel ( channelConfig ) , errorHandler , address , log , config . disableLosslessIntegers ) ;
10099 }
101100
102101 /**
@@ -217,7 +216,7 @@ export default class Connection {
217216 */
218217 _handleFatalError ( error ) {
219218 this . _isBroken = true ;
220- this . _error = this . _errorHandler . handleAndTransformError ( error , this . hostPort ) ;
219+ this . _error = this . _errorHandler . handleAndTransformError ( error , this . address ) ;
221220
222221 if ( this . _log . isErrorEnabled ( ) ) {
223222 this . _log . error ( `${ this } experienced a fatal error ${ JSON . stringify ( this . _error ) } ` ) ;
@@ -267,7 +266,7 @@ export default class Connection {
267266 }
268267 try {
269268 const error = newError ( payload . message , payload . code ) ;
270- this . _currentFailure = this . _errorHandler . handleAndTransformError ( error , this . hostPort ) ;
269+ this . _currentFailure = this . _errorHandler . handleAndTransformError ( error , this . address ) ;
271270 this . _currentObserver . onError ( this . _currentFailure ) ;
272271 } finally {
273272 this . _updateCurrentObserver ( ) ;
0 commit comments