@depup/mongodb 7.1.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/README.md +33 -0
- package/etc/prepare.js +12 -0
- package/lib/admin.js +136 -0
- package/lib/admin.js.map +1 -0
- package/lib/bson.js +85 -0
- package/lib/bson.js.map +1 -0
- package/lib/bulk/common.js +835 -0
- package/lib/bulk/common.js.map +1 -0
- package/lib/bulk/ordered.js +67 -0
- package/lib/bulk/ordered.js.map +1 -0
- package/lib/bulk/unordered.js +92 -0
- package/lib/bulk/unordered.js.map +1 -0
- package/lib/change_stream.js +513 -0
- package/lib/change_stream.js.map +1 -0
- package/lib/client-side-encryption/auto_encrypter.js +272 -0
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -0
- package/lib/client-side-encryption/client_encryption.js +609 -0
- package/lib/client-side-encryption/client_encryption.js.map +1 -0
- package/lib/client-side-encryption/errors.js +138 -0
- package/lib/client-side-encryption/errors.js.map +1 -0
- package/lib/client-side-encryption/mongocryptd_manager.js +85 -0
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -0
- package/lib/client-side-encryption/providers/aws.js +23 -0
- package/lib/client-side-encryption/providers/aws.js.map +1 -0
- package/lib/client-side-encryption/providers/azure.js +132 -0
- package/lib/client-side-encryption/providers/azure.js.map +1 -0
- package/lib/client-side-encryption/providers/gcp.js +16 -0
- package/lib/client-side-encryption/providers/gcp.js.map +1 -0
- package/lib/client-side-encryption/providers/index.js +43 -0
- package/lib/client-side-encryption/providers/index.js.map +1 -0
- package/lib/client-side-encryption/state_machine.js +427 -0
- package/lib/client-side-encryption/state_machine.js.map +1 -0
- package/lib/cmap/auth/auth_provider.js +51 -0
- package/lib/cmap/auth/auth_provider.js.map +1 -0
- package/lib/cmap/auth/aws4.js +161 -0
- package/lib/cmap/auth/aws4.js.map +1 -0
- package/lib/cmap/auth/aws_temporary_credentials.js +103 -0
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
- package/lib/cmap/auth/gssapi.js +155 -0
- package/lib/cmap/auth/gssapi.js.map +1 -0
- package/lib/cmap/auth/mongo_credentials.js +169 -0
- package/lib/cmap/auth/mongo_credentials.js.map +1 -0
- package/lib/cmap/auth/mongodb_aws.js +128 -0
- package/lib/cmap/auth/mongodb_aws.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +84 -0
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +62 -0
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +141 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +44 -0
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +39 -0
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +122 -0
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +32 -0
- package/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/token_cache.js +52 -0
- package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +23 -0
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc.js +73 -0
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -0
- package/lib/cmap/auth/plain.js +26 -0
- package/lib/cmap/auth/plain.js.map +1 -0
- package/lib/cmap/auth/providers.js +22 -0
- package/lib/cmap/auth/providers.js.map +1 -0
- package/lib/cmap/auth/scram.js +254 -0
- package/lib/cmap/auth/scram.js.map +1 -0
- package/lib/cmap/auth/x509.js +36 -0
- package/lib/cmap/auth/x509.js.map +1 -0
- package/lib/cmap/command_monitoring_events.js +223 -0
- package/lib/cmap/command_monitoring_events.js.map +1 -0
- package/lib/cmap/commands.js +535 -0
- package/lib/cmap/commands.js.map +1 -0
- package/lib/cmap/connect.js +381 -0
- package/lib/cmap/connect.js.map +1 -0
- package/lib/cmap/connection.js +571 -0
- package/lib/cmap/connection.js.map +1 -0
- package/lib/cmap/connection_pool.js +558 -0
- package/lib/cmap/connection_pool.js.map +1 -0
- package/lib/cmap/connection_pool_events.js +190 -0
- package/lib/cmap/connection_pool_events.js.map +1 -0
- package/lib/cmap/errors.js +108 -0
- package/lib/cmap/errors.js.map +1 -0
- package/lib/cmap/handshake/client_metadata.js +242 -0
- package/lib/cmap/handshake/client_metadata.js.map +1 -0
- package/lib/cmap/metrics.js +62 -0
- package/lib/cmap/metrics.js.map +1 -0
- package/lib/cmap/stream_description.js +70 -0
- package/lib/cmap/stream_description.js.map +1 -0
- package/lib/cmap/wire_protocol/compression.js +178 -0
- package/lib/cmap/wire_protocol/compression.js.map +1 -0
- package/lib/cmap/wire_protocol/constants.js +21 -0
- package/lib/cmap/wire_protocol/constants.js.map +1 -0
- package/lib/cmap/wire_protocol/on_data.js +111 -0
- package/lib/cmap/wire_protocol/on_data.js.map +1 -0
- package/lib/cmap/wire_protocol/on_demand/document.js +222 -0
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
- package/lib/cmap/wire_protocol/responses.js +315 -0
- package/lib/cmap/wire_protocol/responses.js.map +1 -0
- package/lib/cmap/wire_protocol/shared.js +35 -0
- package/lib/cmap/wire_protocol/shared.js.map +1 -0
- package/lib/collection.js +751 -0
- package/lib/collection.js.map +1 -0
- package/lib/connection_string.js +1090 -0
- package/lib/connection_string.js.map +1 -0
- package/lib/constants.js +170 -0
- package/lib/constants.js.map +1 -0
- package/lib/cursor/abstract_cursor.js +924 -0
- package/lib/cursor/abstract_cursor.js.map +1 -0
- package/lib/cursor/aggregation_cursor.js +164 -0
- package/lib/cursor/aggregation_cursor.js.map +1 -0
- package/lib/cursor/change_stream_cursor.js +104 -0
- package/lib/cursor/change_stream_cursor.js.map +1 -0
- package/lib/cursor/client_bulk_write_cursor.js +52 -0
- package/lib/cursor/client_bulk_write_cursor.js.map +1 -0
- package/lib/cursor/explainable_cursor.js +36 -0
- package/lib/cursor/explainable_cursor.js.map +1 -0
- package/lib/cursor/find_cursor.js +399 -0
- package/lib/cursor/find_cursor.js.map +1 -0
- package/lib/cursor/list_collections_cursor.js +34 -0
- package/lib/cursor/list_collections_cursor.js.map +1 -0
- package/lib/cursor/list_indexes_cursor.js +32 -0
- package/lib/cursor/list_indexes_cursor.js.map +1 -0
- package/lib/cursor/list_search_indexes_cursor.js +14 -0
- package/lib/cursor/list_search_indexes_cursor.js.map +1 -0
- package/lib/cursor/run_command_cursor.js +94 -0
- package/lib/cursor/run_command_cursor.js.map +1 -0
- package/lib/db.js +419 -0
- package/lib/db.js.map +1 -0
- package/lib/deps.js +112 -0
- package/lib/deps.js.map +1 -0
- package/lib/encrypter.js +106 -0
- package/lib/encrypter.js.map +1 -0
- package/lib/error.js +1380 -0
- package/lib/error.js.map +1 -0
- package/lib/explain.js +59 -0
- package/lib/explain.js.map +1 -0
- package/lib/gridfs/download.js +305 -0
- package/lib/gridfs/download.js.map +1 -0
- package/lib/gridfs/index.js +164 -0
- package/lib/gridfs/index.js.map +1 -0
- package/lib/gridfs/upload.js +358 -0
- package/lib/gridfs/upload.js.map +1 -0
- package/lib/index.js +193 -0
- package/lib/index.js.map +1 -0
- package/lib/mongo_client.js +557 -0
- package/lib/mongo_client.js.map +1 -0
- package/lib/mongo_client_auth_providers.js +80 -0
- package/lib/mongo_client_auth_providers.js.map +1 -0
- package/lib/mongo_logger.js +655 -0
- package/lib/mongo_logger.js.map +1 -0
- package/lib/mongo_types.js +56 -0
- package/lib/mongo_types.js.map +1 -0
- package/lib/operations/aggregate.js +90 -0
- package/lib/operations/aggregate.js.map +1 -0
- package/lib/operations/client_bulk_write/client_bulk_write.js +51 -0
- package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -0
- package/lib/operations/client_bulk_write/command_builder.js +340 -0
- package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
- package/lib/operations/client_bulk_write/common.js +3 -0
- package/lib/operations/client_bulk_write/common.js.map +1 -0
- package/lib/operations/client_bulk_write/executor.js +120 -0
- package/lib/operations/client_bulk_write/executor.js.map +1 -0
- package/lib/operations/client_bulk_write/results_merger.js +204 -0
- package/lib/operations/client_bulk_write/results_merger.js.map +1 -0
- package/lib/operations/command.js +83 -0
- package/lib/operations/command.js.map +1 -0
- package/lib/operations/count.js +45 -0
- package/lib/operations/count.js.map +1 -0
- package/lib/operations/create_collection.js +109 -0
- package/lib/operations/create_collection.js.map +1 -0
- package/lib/operations/delete.js +125 -0
- package/lib/operations/delete.js.map +1 -0
- package/lib/operations/distinct.js +61 -0
- package/lib/operations/distinct.js.map +1 -0
- package/lib/operations/drop.js +93 -0
- package/lib/operations/drop.js.map +1 -0
- package/lib/operations/end_sessions.js +34 -0
- package/lib/operations/end_sessions.js.map +1 -0
- package/lib/operations/estimated_document_count.js +41 -0
- package/lib/operations/estimated_document_count.js.map +1 -0
- package/lib/operations/execute_operation.js +239 -0
- package/lib/operations/execute_operation.js.map +1 -0
- package/lib/operations/find.js +148 -0
- package/lib/operations/find.js.map +1 -0
- package/lib/operations/find_and_modify.js +158 -0
- package/lib/operations/find_and_modify.js.map +1 -0
- package/lib/operations/get_more.js +62 -0
- package/lib/operations/get_more.js.map +1 -0
- package/lib/operations/indexes.js +186 -0
- package/lib/operations/indexes.js.map +1 -0
- package/lib/operations/insert.js +70 -0
- package/lib/operations/insert.js.map +1 -0
- package/lib/operations/kill_cursors.js +43 -0
- package/lib/operations/kill_cursors.js.map +1 -0
- package/lib/operations/list_collections.js +53 -0
- package/lib/operations/list_collections.js.map +1 -0
- package/lib/operations/list_databases.js +40 -0
- package/lib/operations/list_databases.js.map +1 -0
- package/lib/operations/operation.js +102 -0
- package/lib/operations/operation.js.map +1 -0
- package/lib/operations/profiling_level.js +43 -0
- package/lib/operations/profiling_level.js.map +1 -0
- package/lib/operations/remove_user.js +27 -0
- package/lib/operations/remove_user.js.map +1 -0
- package/lib/operations/rename.js +38 -0
- package/lib/operations/rename.js.map +1 -0
- package/lib/operations/run_command.js +47 -0
- package/lib/operations/run_command.js.map +1 -0
- package/lib/operations/search_indexes/create.js +33 -0
- package/lib/operations/search_indexes/create.js.map +1 -0
- package/lib/operations/search_indexes/drop.js +43 -0
- package/lib/operations/search_indexes/drop.js.map +1 -0
- package/lib/operations/search_indexes/update.js +35 -0
- package/lib/operations/search_indexes/update.js.map +1 -0
- package/lib/operations/set_profiling_level.js +53 -0
- package/lib/operations/set_profiling_level.js.map +1 -0
- package/lib/operations/stats.js +27 -0
- package/lib/operations/stats.js.map +1 -0
- package/lib/operations/update.js +188 -0
- package/lib/operations/update.js.map +1 -0
- package/lib/operations/validate_collection.js +37 -0
- package/lib/operations/validate_collection.js.map +1 -0
- package/lib/read_concern.js +73 -0
- package/lib/read_concern.js.map +1 -0
- package/lib/read_preference.js +191 -0
- package/lib/read_preference.js.map +1 -0
- package/lib/sdam/common.js +49 -0
- package/lib/sdam/common.js.map +1 -0
- package/lib/sdam/events.js +146 -0
- package/lib/sdam/events.js.map +1 -0
- package/lib/sdam/monitor.js +544 -0
- package/lib/sdam/monitor.js.map +1 -0
- package/lib/sdam/server.js +404 -0
- package/lib/sdam/server.js.map +1 -0
- package/lib/sdam/server_description.js +204 -0
- package/lib/sdam/server_description.js.map +1 -0
- package/lib/sdam/server_selection.js +294 -0
- package/lib/sdam/server_selection.js.map +1 -0
- package/lib/sdam/server_selection_events.js +85 -0
- package/lib/sdam/server_selection_events.js.map +1 -0
- package/lib/sdam/srv_polling.js +108 -0
- package/lib/sdam/srv_polling.js.map +1 -0
- package/lib/sdam/topology.js +652 -0
- package/lib/sdam/topology.js.map +1 -0
- package/lib/sdam/topology_description.js +383 -0
- package/lib/sdam/topology_description.js.map +1 -0
- package/lib/sessions.js +892 -0
- package/lib/sessions.js.map +1 -0
- package/lib/sort.js +103 -0
- package/lib/sort.js.map +1 -0
- package/lib/timeout.js +296 -0
- package/lib/timeout.js.map +1 -0
- package/lib/transactions.js +135 -0
- package/lib/transactions.js.map +1 -0
- package/lib/utils.js +1163 -0
- package/lib/utils.js.map +1 -0
- package/lib/write_concern.js +100 -0
- package/lib/write_concern.js.map +1 -0
- package/mongodb.d.ts +9018 -0
- package/package.json +197 -0
- package/src/admin.ts +173 -0
- package/src/bson.ts +149 -0
- package/src/bulk/common.ts +1251 -0
- package/src/bulk/ordered.ts +83 -0
- package/src/bulk/unordered.ts +115 -0
- package/src/change_stream.ts +1160 -0
- package/src/client-side-encryption/auto_encrypter.ts +469 -0
- package/src/client-side-encryption/client_encryption.ts +1150 -0
- package/src/client-side-encryption/errors.ts +144 -0
- package/src/client-side-encryption/mongocryptd_manager.ts +100 -0
- package/src/client-side-encryption/providers/aws.ts +33 -0
- package/src/client-side-encryption/providers/azure.ts +181 -0
- package/src/client-side-encryption/providers/gcp.ts +16 -0
- package/src/client-side-encryption/providers/index.ts +207 -0
- package/src/client-side-encryption/state_machine.ts +651 -0
- package/src/cmap/auth/auth_provider.ts +77 -0
- package/src/cmap/auth/aws4.ts +207 -0
- package/src/cmap/auth/aws_temporary_credentials.ts +129 -0
- package/src/cmap/auth/gssapi.ts +203 -0
- package/src/cmap/auth/mongo_credentials.ts +292 -0
- package/src/cmap/auth/mongodb_aws.ts +179 -0
- package/src/cmap/auth/mongodb_oidc/automated_callback_workflow.ts +88 -0
- package/src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts +73 -0
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +188 -0
- package/src/cmap/auth/mongodb_oidc/command_builders.ts +53 -0
- package/src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts +46 -0
- package/src/cmap/auth/mongodb_oidc/human_callback_workflow.ts +141 -0
- package/src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts +31 -0
- package/src/cmap/auth/mongodb_oidc/token_cache.ts +62 -0
- package/src/cmap/auth/mongodb_oidc/token_machine_workflow.ts +22 -0
- package/src/cmap/auth/mongodb_oidc.ts +185 -0
- package/src/cmap/auth/plain.ts +25 -0
- package/src/cmap/auth/providers.ts +22 -0
- package/src/cmap/auth/scram.ts +344 -0
- package/src/cmap/auth/x509.ts +43 -0
- package/src/cmap/command_monitoring_events.ts +316 -0
- package/src/cmap/commands.ts +788 -0
- package/src/cmap/connect.ts +518 -0
- package/src/cmap/connection.ts +931 -0
- package/src/cmap/connection_pool.ts +831 -0
- package/src/cmap/connection_pool_events.ts +300 -0
- package/src/cmap/errors.ts +119 -0
- package/src/cmap/handshake/client_metadata.ts +353 -0
- package/src/cmap/metrics.ts +58 -0
- package/src/cmap/stream_description.ts +96 -0
- package/src/cmap/wire_protocol/compression.ts +211 -0
- package/src/cmap/wire_protocol/constants.ts +17 -0
- package/src/cmap/wire_protocol/on_data.ts +139 -0
- package/src/cmap/wire_protocol/on_demand/document.ts +358 -0
- package/src/cmap/wire_protocol/responses.ts +393 -0
- package/src/cmap/wire_protocol/shared.ts +48 -0
- package/src/collection.ts +1314 -0
- package/src/connection_string.ts +1297 -0
- package/src/constants.ts +176 -0
- package/src/cursor/abstract_cursor.ts +1247 -0
- package/src/cursor/aggregation_cursor.ts +245 -0
- package/src/cursor/change_stream_cursor.ts +171 -0
- package/src/cursor/client_bulk_write_cursor.ts +83 -0
- package/src/cursor/explainable_cursor.ts +51 -0
- package/src/cursor/find_cursor.ts +497 -0
- package/src/cursor/list_collections_cursor.ts +50 -0
- package/src/cursor/list_indexes_cursor.ts +37 -0
- package/src/cursor/list_search_indexes_cursor.ts +20 -0
- package/src/cursor/run_command_cursor.ts +178 -0
- package/src/db.ts +621 -0
- package/src/deps.ts +227 -0
- package/src/encrypter.ts +127 -0
- package/src/error.ts +1567 -0
- package/src/explain.ts +124 -0
- package/src/gridfs/download.ts +483 -0
- package/src/gridfs/index.ts +264 -0
- package/src/gridfs/upload.ts +537 -0
- package/src/index.ts +633 -0
- package/src/mongo_client.ts +1155 -0
- package/src/mongo_client_auth_providers.ts +87 -0
- package/src/mongo_logger.ts +1081 -0
- package/src/mongo_types.ts +678 -0
- package/src/operations/aggregate.ts +153 -0
- package/src/operations/client_bulk_write/client_bulk_write.ts +72 -0
- package/src/operations/client_bulk_write/command_builder.ts +487 -0
- package/src/operations/client_bulk_write/common.ts +276 -0
- package/src/operations/client_bulk_write/executor.ts +149 -0
- package/src/operations/client_bulk_write/results_merger.ts +260 -0
- package/src/operations/command.ts +171 -0
- package/src/operations/count.ts +74 -0
- package/src/operations/create_collection.ts +218 -0
- package/src/operations/delete.ts +183 -0
- package/src/operations/distinct.ts +92 -0
- package/src/operations/drop.ts +130 -0
- package/src/operations/end_sessions.ts +44 -0
- package/src/operations/estimated_document_count.ts +61 -0
- package/src/operations/execute_operation.ts +319 -0
- package/src/operations/find.ts +254 -0
- package/src/operations/find_and_modify.ts +319 -0
- package/src/operations/get_more.ts +108 -0
- package/src/operations/indexes.ts +418 -0
- package/src/operations/insert.ts +108 -0
- package/src/operations/kill_cursors.ts +64 -0
- package/src/operations/list_collections.ts +108 -0
- package/src/operations/list_databases.ts +68 -0
- package/src/operations/operation.ts +181 -0
- package/src/operations/profiling_level.ts +46 -0
- package/src/operations/remove_user.ts +36 -0
- package/src/operations/rename.ts +60 -0
- package/src/operations/run_command.ts +79 -0
- package/src/operations/search_indexes/create.ts +56 -0
- package/src/operations/search_indexes/drop.ts +58 -0
- package/src/operations/search_indexes/update.ts +45 -0
- package/src/operations/set_profiling_level.ts +74 -0
- package/src/operations/stats.ts +37 -0
- package/src/operations/update.ts +318 -0
- package/src/operations/validate_collection.ts +50 -0
- package/src/read_concern.ts +88 -0
- package/src/read_preference.ts +256 -0
- package/src/sdam/common.ts +74 -0
- package/src/sdam/events.ts +219 -0
- package/src/sdam/monitor.ts +771 -0
- package/src/sdam/server.ts +595 -0
- package/src/sdam/server_description.ts +297 -0
- package/src/sdam/server_selection.ts +415 -0
- package/src/sdam/server_selection_events.ts +142 -0
- package/src/sdam/srv_polling.ts +146 -0
- package/src/sdam/topology.ts +1100 -0
- package/src/sdam/topology_description.ts +548 -0
- package/src/sessions.ts +1244 -0
- package/src/sort.ts +141 -0
- package/src/timeout.ts +405 -0
- package/src/transactions.ts +181 -0
- package/src/utils.ts +1434 -0
- package/src/write_concern.ts +183 -0
- package/tsconfig.json +46 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import type { ObjectId } from '../bson';
|
|
2
|
+
import {
|
|
3
|
+
CONNECTION_CHECK_OUT_FAILED,
|
|
4
|
+
CONNECTION_CHECK_OUT_STARTED,
|
|
5
|
+
CONNECTION_CHECKED_IN,
|
|
6
|
+
CONNECTION_CHECKED_OUT,
|
|
7
|
+
CONNECTION_CLOSED,
|
|
8
|
+
CONNECTION_CREATED,
|
|
9
|
+
CONNECTION_POOL_CLEARED,
|
|
10
|
+
CONNECTION_POOL_CLOSED,
|
|
11
|
+
CONNECTION_POOL_CREATED,
|
|
12
|
+
CONNECTION_POOL_READY,
|
|
13
|
+
CONNECTION_READY
|
|
14
|
+
} from '../constants';
|
|
15
|
+
import type { MongoError } from '../error';
|
|
16
|
+
import { processTimeMS } from '../utils';
|
|
17
|
+
import type { Connection } from './connection';
|
|
18
|
+
import type { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The base export class for all monitoring events published from the connection pool
|
|
22
|
+
* @public
|
|
23
|
+
* @category Event
|
|
24
|
+
*/
|
|
25
|
+
export abstract class ConnectionPoolMonitoringEvent {
|
|
26
|
+
/** A timestamp when the event was created */
|
|
27
|
+
time: Date;
|
|
28
|
+
/** The address (host/port pair) of the pool */
|
|
29
|
+
address: string;
|
|
30
|
+
/** @internal */
|
|
31
|
+
abstract name:
|
|
32
|
+
| typeof CONNECTION_CHECK_OUT_FAILED
|
|
33
|
+
| typeof CONNECTION_CHECK_OUT_STARTED
|
|
34
|
+
| typeof CONNECTION_CHECKED_IN
|
|
35
|
+
| typeof CONNECTION_CHECKED_OUT
|
|
36
|
+
| typeof CONNECTION_CLOSED
|
|
37
|
+
| typeof CONNECTION_CREATED
|
|
38
|
+
| typeof CONNECTION_POOL_CLEARED
|
|
39
|
+
| typeof CONNECTION_POOL_CLOSED
|
|
40
|
+
| typeof CONNECTION_POOL_CREATED
|
|
41
|
+
| typeof CONNECTION_POOL_READY
|
|
42
|
+
| typeof CONNECTION_READY;
|
|
43
|
+
|
|
44
|
+
/** @internal */
|
|
45
|
+
constructor(pool: ConnectionPool) {
|
|
46
|
+
this.time = new Date();
|
|
47
|
+
this.address = pool.address;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An event published when a connection pool is created
|
|
53
|
+
* @public
|
|
54
|
+
* @category Event
|
|
55
|
+
*/
|
|
56
|
+
export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
|
|
57
|
+
/** The options used to create this connection pool */
|
|
58
|
+
options: Pick<
|
|
59
|
+
ConnectionPoolOptions,
|
|
60
|
+
'maxPoolSize' | 'minPoolSize' | 'maxConnecting' | 'maxIdleTimeMS' | 'waitQueueTimeoutMS'
|
|
61
|
+
>;
|
|
62
|
+
/** @internal */
|
|
63
|
+
name = CONNECTION_POOL_CREATED;
|
|
64
|
+
|
|
65
|
+
/** @internal */
|
|
66
|
+
constructor(pool: ConnectionPool) {
|
|
67
|
+
super(pool);
|
|
68
|
+
const { maxConnecting, maxPoolSize, minPoolSize, maxIdleTimeMS, waitQueueTimeoutMS } =
|
|
69
|
+
pool.options;
|
|
70
|
+
this.options = { maxConnecting, maxPoolSize, minPoolSize, maxIdleTimeMS, waitQueueTimeoutMS };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* An event published when a connection pool is ready
|
|
76
|
+
* @public
|
|
77
|
+
* @category Event
|
|
78
|
+
*/
|
|
79
|
+
export class ConnectionPoolReadyEvent extends ConnectionPoolMonitoringEvent {
|
|
80
|
+
/** @internal */
|
|
81
|
+
name = CONNECTION_POOL_READY;
|
|
82
|
+
|
|
83
|
+
/** @internal */
|
|
84
|
+
constructor(pool: ConnectionPool) {
|
|
85
|
+
super(pool);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An event published when a connection pool is closed
|
|
91
|
+
* @public
|
|
92
|
+
* @category Event
|
|
93
|
+
*/
|
|
94
|
+
export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
|
|
95
|
+
/** @internal */
|
|
96
|
+
name = CONNECTION_POOL_CLOSED;
|
|
97
|
+
|
|
98
|
+
/** @internal */
|
|
99
|
+
constructor(pool: ConnectionPool) {
|
|
100
|
+
super(pool);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* An event published when a connection pool creates a new connection
|
|
106
|
+
* @public
|
|
107
|
+
* @category Event
|
|
108
|
+
*/
|
|
109
|
+
export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
|
|
110
|
+
/** A monotonically increasing, per-pool id for the newly created connection */
|
|
111
|
+
connectionId: number | '<monitor>';
|
|
112
|
+
/** @internal */
|
|
113
|
+
name = CONNECTION_CREATED;
|
|
114
|
+
|
|
115
|
+
/** @internal */
|
|
116
|
+
constructor(pool: ConnectionPool, connection: { id: number | '<monitor>' }) {
|
|
117
|
+
super(pool);
|
|
118
|
+
this.connectionId = connection.id;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* An event published when a connection is ready for use
|
|
124
|
+
* @public
|
|
125
|
+
* @category Event
|
|
126
|
+
*/
|
|
127
|
+
export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
|
|
128
|
+
/** The id of the connection */
|
|
129
|
+
connectionId: number | '<monitor>';
|
|
130
|
+
/**
|
|
131
|
+
* The time it took to establish the connection.
|
|
132
|
+
* In accordance with the definition of establishment of a connection
|
|
133
|
+
* specified by `ConnectionPoolOptions.maxConnecting`,
|
|
134
|
+
* it is the time elapsed between emitting a `ConnectionCreatedEvent`
|
|
135
|
+
* and emitting this event as part of the same checking out.
|
|
136
|
+
*
|
|
137
|
+
* Naturally, when establishing a connection is part of checking out,
|
|
138
|
+
* this duration is not greater than
|
|
139
|
+
* `ConnectionCheckedOutEvent.duration`.
|
|
140
|
+
*/
|
|
141
|
+
durationMS: number;
|
|
142
|
+
/** @internal */
|
|
143
|
+
name = CONNECTION_READY;
|
|
144
|
+
|
|
145
|
+
/** @internal */
|
|
146
|
+
constructor(pool: ConnectionPool, connection: Connection, connectionCreatedEventTime: number) {
|
|
147
|
+
super(pool);
|
|
148
|
+
this.durationMS = processTimeMS() - connectionCreatedEventTime;
|
|
149
|
+
this.connectionId = connection.id;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* An event published when a connection is closed
|
|
155
|
+
* @public
|
|
156
|
+
* @category Event
|
|
157
|
+
*/
|
|
158
|
+
export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
|
|
159
|
+
/** The id of the connection */
|
|
160
|
+
connectionId: number | '<monitor>';
|
|
161
|
+
/** The reason the connection was closed */
|
|
162
|
+
reason: string;
|
|
163
|
+
serviceId?: ObjectId;
|
|
164
|
+
/** @internal */
|
|
165
|
+
name = CONNECTION_CLOSED;
|
|
166
|
+
/** @internal */
|
|
167
|
+
error: MongoError | null;
|
|
168
|
+
|
|
169
|
+
/** @internal */
|
|
170
|
+
constructor(
|
|
171
|
+
pool: ConnectionPool,
|
|
172
|
+
connection: Pick<Connection, 'id' | 'serviceId'>,
|
|
173
|
+
reason: 'idle' | 'stale' | 'poolClosed' | 'error',
|
|
174
|
+
error?: MongoError
|
|
175
|
+
) {
|
|
176
|
+
super(pool);
|
|
177
|
+
this.connectionId = connection.id;
|
|
178
|
+
this.reason = reason;
|
|
179
|
+
this.serviceId = connection.serviceId;
|
|
180
|
+
this.error = error ?? null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* An event published when a request to check a connection out begins
|
|
186
|
+
* @public
|
|
187
|
+
* @category Event
|
|
188
|
+
*/
|
|
189
|
+
export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEvent {
|
|
190
|
+
/** @internal */
|
|
191
|
+
name = CONNECTION_CHECK_OUT_STARTED;
|
|
192
|
+
|
|
193
|
+
/** @internal */
|
|
194
|
+
constructor(pool: ConnectionPool) {
|
|
195
|
+
super(pool);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* An event published when a request to check a connection out fails
|
|
201
|
+
* @public
|
|
202
|
+
* @category Event
|
|
203
|
+
*/
|
|
204
|
+
export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent {
|
|
205
|
+
/** The reason the attempt to check out failed */
|
|
206
|
+
reason: string;
|
|
207
|
+
/** @internal */
|
|
208
|
+
error?: MongoError;
|
|
209
|
+
/** @internal */
|
|
210
|
+
name = CONNECTION_CHECK_OUT_FAILED;
|
|
211
|
+
/**
|
|
212
|
+
* The time it took to check out the connection.
|
|
213
|
+
* More specifically, the time elapsed between
|
|
214
|
+
* emitting a `ConnectionCheckOutStartedEvent`
|
|
215
|
+
* and emitting this event as part of the same check out.
|
|
216
|
+
*/
|
|
217
|
+
durationMS: number;
|
|
218
|
+
|
|
219
|
+
/** @internal */
|
|
220
|
+
constructor(
|
|
221
|
+
pool: ConnectionPool,
|
|
222
|
+
reason: 'poolClosed' | 'timeout' | 'connectionError',
|
|
223
|
+
checkoutTime: number,
|
|
224
|
+
error?: MongoError
|
|
225
|
+
) {
|
|
226
|
+
super(pool);
|
|
227
|
+
this.durationMS = processTimeMS() - checkoutTime;
|
|
228
|
+
this.reason = reason;
|
|
229
|
+
this.error = error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* An event published when a connection is checked out of the connection pool
|
|
235
|
+
* @public
|
|
236
|
+
* @category Event
|
|
237
|
+
*/
|
|
238
|
+
export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
|
|
239
|
+
/** The id of the connection */
|
|
240
|
+
connectionId: number | '<monitor>';
|
|
241
|
+
/** @internal */
|
|
242
|
+
name = CONNECTION_CHECKED_OUT;
|
|
243
|
+
/**
|
|
244
|
+
* The time it took to check out the connection.
|
|
245
|
+
* More specifically, the time elapsed between
|
|
246
|
+
* emitting a `ConnectionCheckOutStartedEvent`
|
|
247
|
+
* and emitting this event as part of the same checking out.
|
|
248
|
+
*
|
|
249
|
+
*/
|
|
250
|
+
durationMS: number;
|
|
251
|
+
|
|
252
|
+
/** @internal */
|
|
253
|
+
constructor(pool: ConnectionPool, connection: Connection, checkoutTime: number) {
|
|
254
|
+
super(pool);
|
|
255
|
+
this.durationMS = processTimeMS() - checkoutTime;
|
|
256
|
+
this.connectionId = connection.id;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* An event published when a connection is checked into the connection pool
|
|
262
|
+
* @public
|
|
263
|
+
* @category Event
|
|
264
|
+
*/
|
|
265
|
+
export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
|
|
266
|
+
/** The id of the connection */
|
|
267
|
+
connectionId: number | '<monitor>';
|
|
268
|
+
/** @internal */
|
|
269
|
+
name = CONNECTION_CHECKED_IN;
|
|
270
|
+
|
|
271
|
+
/** @internal */
|
|
272
|
+
constructor(pool: ConnectionPool, connection: Connection) {
|
|
273
|
+
super(pool);
|
|
274
|
+
this.connectionId = connection.id;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* An event published when a connection pool is cleared
|
|
280
|
+
* @public
|
|
281
|
+
* @category Event
|
|
282
|
+
*/
|
|
283
|
+
export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
|
|
284
|
+
/** @internal */
|
|
285
|
+
serviceId?: ObjectId;
|
|
286
|
+
|
|
287
|
+
interruptInUseConnections?: boolean;
|
|
288
|
+
/** @internal */
|
|
289
|
+
name = CONNECTION_POOL_CLEARED;
|
|
290
|
+
|
|
291
|
+
/** @internal */
|
|
292
|
+
constructor(
|
|
293
|
+
pool: ConnectionPool,
|
|
294
|
+
options: { serviceId?: ObjectId; interruptInUseConnections?: boolean } = {}
|
|
295
|
+
) {
|
|
296
|
+
super(pool);
|
|
297
|
+
this.serviceId = options.serviceId;
|
|
298
|
+
this.interruptInUseConnections = options.interruptInUseConnections;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { MongoDriverError, MongoErrorLabel, MongoNetworkError } from '../error';
|
|
2
|
+
import type { ConnectionPool } from './connection_pool';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An error indicating a connection pool is closed
|
|
6
|
+
* @category Error
|
|
7
|
+
*/
|
|
8
|
+
export class PoolClosedError extends MongoDriverError {
|
|
9
|
+
/** The address of the connection pool */
|
|
10
|
+
address: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* **Do not use this constructor!**
|
|
14
|
+
*
|
|
15
|
+
* Meant for internal use only.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This class is only meant to be constructed within the driver. This constructor is
|
|
19
|
+
* not subject to semantic versioning compatibility guarantees and may change at any time.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
**/
|
|
23
|
+
constructor(pool: ConnectionPool) {
|
|
24
|
+
super('Attempted to check out a connection from closed connection pool');
|
|
25
|
+
this.address = pool.address;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override get name(): string {
|
|
29
|
+
return 'MongoPoolClosedError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An error indicating a connection pool is currently paused
|
|
35
|
+
* @category Error
|
|
36
|
+
*/
|
|
37
|
+
export class PoolClearedError extends MongoNetworkError {
|
|
38
|
+
/** The address of the connection pool */
|
|
39
|
+
address: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* **Do not use this constructor!**
|
|
43
|
+
*
|
|
44
|
+
* Meant for internal use only.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This class is only meant to be constructed within the driver. This constructor is
|
|
48
|
+
* not subject to semantic versioning compatibility guarantees and may change at any time.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
**/
|
|
52
|
+
constructor(pool: ConnectionPool, message?: string) {
|
|
53
|
+
const errorMessage = message
|
|
54
|
+
? message
|
|
55
|
+
: `Connection pool for ${pool.address} was cleared because another operation failed with: "${pool.serverError?.message}"`;
|
|
56
|
+
super(errorMessage, pool.serverError ? { cause: pool.serverError } : undefined);
|
|
57
|
+
this.address = pool.address;
|
|
58
|
+
|
|
59
|
+
this.addErrorLabel(MongoErrorLabel.PoolRequestedRetry);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override get name(): string {
|
|
63
|
+
return 'MongoPoolClearedError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* An error indicating that a connection pool has been cleared after the monitor for that server timed out.
|
|
69
|
+
* @category Error
|
|
70
|
+
*/
|
|
71
|
+
export class PoolClearedOnNetworkError extends PoolClearedError {
|
|
72
|
+
/**
|
|
73
|
+
* **Do not use this constructor!**
|
|
74
|
+
*
|
|
75
|
+
* Meant for internal use only.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This class is only meant to be constructed within the driver. This constructor is
|
|
79
|
+
* not subject to semantic versioning compatibility guarantees and may change at any time.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
**/
|
|
83
|
+
constructor(pool: ConnectionPool) {
|
|
84
|
+
super(pool, `Connection to ${pool.address} interrupted due to server monitor timeout`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
override get name(): string {
|
|
88
|
+
return 'PoolClearedOnNetworkError';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* An error thrown when a request to check out a connection times out
|
|
94
|
+
* @category Error
|
|
95
|
+
*/
|
|
96
|
+
export class WaitQueueTimeoutError extends MongoDriverError {
|
|
97
|
+
/** The address of the connection pool */
|
|
98
|
+
address: string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* **Do not use this constructor!**
|
|
102
|
+
*
|
|
103
|
+
* Meant for internal use only.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* This class is only meant to be constructed within the driver. This constructor is
|
|
107
|
+
* not subject to semantic versioning compatibility guarantees and may change at any time.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
**/
|
|
111
|
+
constructor(message: string, address: string) {
|
|
112
|
+
super(message);
|
|
113
|
+
this.address = address;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
override get name(): string {
|
|
117
|
+
return 'MongoWaitQueueTimeoutError';
|
|
118
|
+
}
|
|
119
|
+
}
|