1
1
import { GetMore , KillCursor , Msg , WriteProtocolMessageType } from './commands' ;
2
2
import { calculateDurationInMs , deepCopy } from '../utils' ;
3
- import type { ConnectionPool , ConnectionPoolOptions } from './connection_pool' ;
3
+ import { ConnectionPool , ConnectionPoolOptions } from './connection_pool' ;
4
4
import type { Connection } from './connection' ;
5
5
import type { Document } from '../bson' ;
6
6
import type { AnyError } from '../error' ;
7
7
8
8
/**
9
9
* The base export class for all monitoring events published from the connection pool
10
+ * @public
10
11
* @category Event
11
12
*/
12
13
export class ConnectionPoolMonitoringEvent {
@@ -23,6 +24,7 @@ export class ConnectionPoolMonitoringEvent {
23
24
24
25
/**
25
26
* An event published when a connection pool is created
27
+ * @public
26
28
* @category Event
27
29
*/
28
30
export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
@@ -37,6 +39,7 @@ export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
37
39
38
40
/**
39
41
* An event published when a connection pool is closed
42
+ * @public
40
43
* @category Event
41
44
*/
42
45
export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
@@ -47,6 +50,7 @@ export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
47
50
48
51
/**
49
52
* An event published when a connection pool creates a new connection
53
+ * @public
50
54
* @category Event
51
55
*/
52
56
export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
@@ -61,6 +65,7 @@ export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
61
65
62
66
/**
63
67
* An event published when a connection is ready for use
68
+ * @public
64
69
* @category Event
65
70
*/
66
71
export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
@@ -75,6 +80,7 @@ export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
75
80
76
81
/**
77
82
* An event published when a connection is closed
83
+ * @public
78
84
* @category Event
79
85
*/
80
86
export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
@@ -90,7 +96,11 @@ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
90
96
}
91
97
}
92
98
93
- /** An event published when a request to check a connection out begins @category Event */
99
+ /**
100
+ * An event published when a request to check a connection out begins
101
+ * @public
102
+ * @category Event
103
+ */
94
104
export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEvent {
95
105
constructor ( pool : ConnectionPool ) {
96
106
super ( pool ) ;
@@ -99,6 +109,7 @@ export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEven
99
109
100
110
/**
101
111
* An event published when a request to check a connection out fails
112
+ * @public
102
113
* @category Event
103
114
*/
104
115
export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent {
@@ -113,6 +124,7 @@ export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent
113
124
114
125
/**
115
126
* An event published when a connection is checked out of the connection pool
127
+ * @public
116
128
* @category Event
117
129
*/
118
130
export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
@@ -127,6 +139,7 @@ export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
127
139
128
140
/**
129
141
* An event published when a connection is checked into the connection pool
142
+ * @public
130
143
* @category Event
131
144
*/
132
145
export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
@@ -141,6 +154,7 @@ export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
141
154
142
155
/**
143
156
* An event published when a connection pool is cleared
157
+ * @public
144
158
* @category Event
145
159
*/
146
160
export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
@@ -150,20 +164,21 @@ export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
150
164
}
151
165
152
166
export const CMAP_EVENT_NAMES = [
153
- 'connectionPoolCreated' ,
154
- 'connectionPoolClosed' ,
155
- 'connectionCreated' ,
156
- 'connectionReady' ,
157
- 'connectionClosed' ,
158
- 'connectionCheckOutStarted' ,
159
- 'connectionCheckOutFailed' ,
160
- 'connectionCheckedOut' ,
161
- 'connectionCheckedIn' ,
162
- 'connectionPoolCleared'
163
- ] ;
167
+ ConnectionPool . CONNECTION_POOL_CREATED ,
168
+ ConnectionPool . CONNECTION_POOL_CLOSED ,
169
+ ConnectionPool . CONNECTION_CREATED ,
170
+ ConnectionPool . CONNECTION_READY ,
171
+ ConnectionPool . CONNECTION_CLOSED ,
172
+ ConnectionPool . CONNECTION_CHECK_OUT_STARTED ,
173
+ ConnectionPool . CONNECTION_CHECK_OUT_FAILED ,
174
+ ConnectionPool . CONNECTION_CHECKED_OUT ,
175
+ ConnectionPool . CONNECTION_CHECKED_IN ,
176
+ ConnectionPool . CONNECTION_POOL_CLEARED
177
+ ] as const ;
164
178
165
179
/**
166
180
* An event indicating the start of a given
181
+ * @public
167
182
* @category Event
168
183
*/
169
184
export class CommandStartedEvent {
@@ -178,6 +193,7 @@ export class CommandStartedEvent {
178
193
/**
179
194
* Create a started event
180
195
*
196
+ * @internal
181
197
* @param pool - the pool that originated the command
182
198
* @param command - the command
183
199
*/
@@ -203,6 +219,7 @@ export class CommandStartedEvent {
203
219
204
220
/**
205
221
* An event indicating the success of a given command
222
+ * @public
206
223
* @category Event
207
224
*/
208
225
export class CommandSucceededEvent {
@@ -216,6 +233,7 @@ export class CommandSucceededEvent {
216
233
/**
217
234
* Create a succeeded event
218
235
*
236
+ * @internal
219
237
* @param pool - the pool that originated the command
220
238
* @param command - the command
221
239
* @param reply - the reply for this command from the server
@@ -242,6 +260,7 @@ export class CommandSucceededEvent {
242
260
243
261
/**
244
262
* An event indicating the failure of a given command
263
+ * @public
245
264
* @category Event
246
265
*/
247
266
export class CommandFailedEvent {
@@ -254,6 +273,7 @@ export class CommandFailedEvent {
254
273
/**
255
274
* Create a failure event
256
275
*
276
+ * @internal
257
277
* @param pool - the pool that originated the command
258
278
* @param command - the command
259
279
* @param error - the generated error or a server error response
0 commit comments