@@ -50,14 +50,14 @@ export default class Connection {
50
50
* @constructor
51
51
* @param {Channel } channel - channel with a 'write' function and a 'onmessage' callback property.
52
52
* @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.
54
54
* @param {Logger } log - the configured logger.
55
55
* @param {boolean } disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
56
56
*/
57
- constructor ( channel , errorHandler , hostPort , log , disableLosslessIntegers = false ) {
57
+ constructor ( channel , errorHandler , address , log , disableLosslessIntegers = false ) {
58
58
this . id = idGenerator ++ ;
59
- this . hostPort = hostPort ;
60
- this . server = { address : hostPort } ;
59
+ this . address = address ;
60
+ this . server = { address : address . asHostPort ( ) } ;
61
61
this . creationTimestamp = Date . now ( ) ;
62
62
this . _errorHandler = errorHandler ;
63
63
this . _disableLosslessIntegers = disableLosslessIntegers ;
@@ -81,22 +81,21 @@ export default class Connection {
81
81
this . _isBroken = false ;
82
82
83
83
if ( this . _log . isDebugEnabled ( ) ) {
84
- this . _log . debug ( `${ this } created towards ${ hostPort } ` ) ;
84
+ this . _log . debug ( `${ this } created towards ${ address } ` ) ;
85
85
}
86
86
}
87
87
88
88
/**
89
89
* 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.
91
91
* @param {object } config - this driver configuration.
92
92
* @param {ConnectionErrorHandler } errorHandler - the error handler for connection errors.
93
93
* @param {Logger } log - configured logger.
94
94
* @return {Connection } - new connection.
95
95
*/
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 ) ;
100
99
}
101
100
102
101
/**
@@ -217,7 +216,7 @@ export default class Connection {
217
216
*/
218
217
_handleFatalError ( error ) {
219
218
this . _isBroken = true ;
220
- this . _error = this . _errorHandler . handleAndTransformError ( error , this . hostPort ) ;
219
+ this . _error = this . _errorHandler . handleAndTransformError ( error , this . address ) ;
221
220
222
221
if ( this . _log . isErrorEnabled ( ) ) {
223
222
this . _log . error ( `${ this } experienced a fatal error ${ JSON . stringify ( this . _error ) } ` ) ;
@@ -267,7 +266,7 @@ export default class Connection {
267
266
}
268
267
try {
269
268
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 ) ;
271
270
this . _currentObserver . onError ( this . _currentFailure ) ;
272
271
} finally {
273
272
this . _updateCurrentObserver ( ) ;
0 commit comments