You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/sdam/server_selection_events.ts
+14-9Lines changed: 14 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
import{HostAddress}from'.././utils';
1
2
import{
2
3
SERVER_SELECTION_FAILED,
3
4
SERVER_SELECTION_STARTED,
@@ -36,10 +37,10 @@ export abstract class ServerSelectionEvent {
36
37
constructor(
37
38
selector: string|ReadPreference|ServerSelector,
38
39
topologyDescription: TopologyDescription,
39
-
operation?: string
40
+
operation: string
40
41
){
41
42
this.selector=selector;
42
-
this.operation=operation??'n/a';
43
+
this.operation=operation;
43
44
this.topologyDescription=topologyDescription;
44
45
}
45
46
}
@@ -58,7 +59,7 @@ export class ServerSelectionStartedEvent extends ServerSelectionEvent {
58
59
constructor(
59
60
selector: string|ReadPreference|ServerSelector,
60
61
topologyDescription: TopologyDescription,
61
-
operation?: string
62
+
operation: string
62
63
){
63
64
super(selector,topologyDescription,operation);
64
65
}
@@ -81,7 +82,7 @@ export class ServerSelectionFailedEvent extends ServerSelectionEvent {
81
82
selector: string|ReadPreference|ServerSelector,
82
83
topologyDescription: TopologyDescription,
83
84
error: Error,
84
-
operation?: string
85
+
operation: string
85
86
){
86
87
super(selector,topologyDescription,operation);
87
88
this.failure=error;
@@ -97,18 +98,22 @@ export class ServerSelectionSucceededEvent extends ServerSelectionEvent {
97
98
/** @internal */
98
99
name=SERVER_SELECTION_SUCCEEDED;
99
100
message='Server selection succeeded';
100
-
/** The address (host/port pair) of the pool */
101
-
address: string;
101
+
/** The hostname, IP address, or Unix domain socket path for the selected server. */
102
+
serverHost: string;
103
+
/** The port for the selected server. Optional; not present for Unix domain sockets. When the user does not specify a port and the default (27017) is used, the driver SHOULD include it here. */
104
+
serverPort: number|undefined;
102
105
103
106
/** @internal */
104
107
constructor(
105
108
selector: string|ReadPreference|ServerSelector,
106
109
topologyDescription: TopologyDescription,
107
110
address: string,
108
-
operation?: string
111
+
operation: string
109
112
){
110
113
super(selector,topologyDescription,operation);
111
-
this.address=address;
114
+
const{ host, port }=HostAddress.fromString(address).toHostPort();
115
+
this.serverHost=host;
116
+
this.serverPort=port;
112
117
}
113
118
}
114
119
@@ -129,7 +134,7 @@ export class WaitingForSuitableServerEvent extends ServerSelectionEvent {
0 commit comments