@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,256 @@
|
|
|
1
|
+
import type { Document } from './bson';
|
|
2
|
+
import { MongoInvalidArgumentError } from './error';
|
|
3
|
+
import type { TagSet } from './sdam/server_description';
|
|
4
|
+
import type { ClientSession } from './sessions';
|
|
5
|
+
|
|
6
|
+
/** @public */
|
|
7
|
+
export type ReadPreferenceLike = ReadPreference | ReadPreferenceMode;
|
|
8
|
+
|
|
9
|
+
/** @public */
|
|
10
|
+
export const ReadPreferenceMode = Object.freeze({
|
|
11
|
+
primary: 'primary',
|
|
12
|
+
primaryPreferred: 'primaryPreferred',
|
|
13
|
+
secondary: 'secondary',
|
|
14
|
+
secondaryPreferred: 'secondaryPreferred',
|
|
15
|
+
nearest: 'nearest'
|
|
16
|
+
} as const);
|
|
17
|
+
|
|
18
|
+
/** @public */
|
|
19
|
+
export type ReadPreferenceMode = (typeof ReadPreferenceMode)[keyof typeof ReadPreferenceMode];
|
|
20
|
+
|
|
21
|
+
/** @public */
|
|
22
|
+
export interface HedgeOptions {
|
|
23
|
+
/** Explicitly enable or disable hedged reads. */
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @public */
|
|
28
|
+
export interface ReadPreferenceOptions {
|
|
29
|
+
/** Max secondary read staleness in seconds, Minimum value is 90 seconds.*/
|
|
30
|
+
maxStalenessSeconds?: number;
|
|
31
|
+
/** Server mode in which the same query is dispatched in parallel to multiple replica set members. */
|
|
32
|
+
hedge?: HedgeOptions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @public */
|
|
36
|
+
export interface ReadPreferenceLikeOptions extends ReadPreferenceOptions {
|
|
37
|
+
readPreference?:
|
|
38
|
+
| ReadPreferenceLike
|
|
39
|
+
| {
|
|
40
|
+
mode?: ReadPreferenceMode;
|
|
41
|
+
preference?: ReadPreferenceMode;
|
|
42
|
+
tags?: TagSet[];
|
|
43
|
+
maxStalenessSeconds?: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** @public */
|
|
48
|
+
export interface ReadPreferenceFromOptions extends ReadPreferenceLikeOptions {
|
|
49
|
+
session?: ClientSession;
|
|
50
|
+
readPreferenceTags?: TagSet[];
|
|
51
|
+
hedge?: HedgeOptions;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The **ReadPreference** class is a class that represents a MongoDB ReadPreference and is
|
|
56
|
+
* used to construct connections.
|
|
57
|
+
* @public
|
|
58
|
+
*
|
|
59
|
+
* @see https://www.mongodb.com/docs/manual/core/read-preference/
|
|
60
|
+
*/
|
|
61
|
+
export class ReadPreference {
|
|
62
|
+
mode: ReadPreferenceMode;
|
|
63
|
+
tags?: TagSet[];
|
|
64
|
+
hedge?: HedgeOptions;
|
|
65
|
+
maxStalenessSeconds?: number;
|
|
66
|
+
|
|
67
|
+
public static PRIMARY = ReadPreferenceMode.primary;
|
|
68
|
+
public static PRIMARY_PREFERRED = ReadPreferenceMode.primaryPreferred;
|
|
69
|
+
public static SECONDARY = ReadPreferenceMode.secondary;
|
|
70
|
+
public static SECONDARY_PREFERRED = ReadPreferenceMode.secondaryPreferred;
|
|
71
|
+
public static NEAREST = ReadPreferenceMode.nearest;
|
|
72
|
+
|
|
73
|
+
public static primary = new ReadPreference(ReadPreferenceMode.primary);
|
|
74
|
+
public static primaryPreferred = new ReadPreference(ReadPreferenceMode.primaryPreferred);
|
|
75
|
+
public static secondary = new ReadPreference(ReadPreferenceMode.secondary);
|
|
76
|
+
public static secondaryPreferred = new ReadPreference(ReadPreferenceMode.secondaryPreferred);
|
|
77
|
+
public static nearest = new ReadPreference(ReadPreferenceMode.nearest);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param mode - A string describing the read preference mode (primary|primaryPreferred|secondary|secondaryPreferred|nearest)
|
|
81
|
+
* @param tags - A tag set used to target reads to members with the specified tag(s). tagSet is not available if using read preference mode primary.
|
|
82
|
+
* @param options - Additional read preference options
|
|
83
|
+
*/
|
|
84
|
+
constructor(mode: ReadPreferenceMode, tags?: TagSet[], options?: ReadPreferenceOptions) {
|
|
85
|
+
if (!ReadPreference.isValid(mode)) {
|
|
86
|
+
throw new MongoInvalidArgumentError(`Invalid read preference mode ${JSON.stringify(mode)}`);
|
|
87
|
+
}
|
|
88
|
+
if (options == null && typeof tags === 'object' && !Array.isArray(tags)) {
|
|
89
|
+
options = tags;
|
|
90
|
+
tags = undefined;
|
|
91
|
+
} else if (tags && !Array.isArray(tags)) {
|
|
92
|
+
throw new MongoInvalidArgumentError('ReadPreference tags must be an array');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.mode = mode;
|
|
96
|
+
this.tags = tags;
|
|
97
|
+
this.hedge = options?.hedge;
|
|
98
|
+
this.maxStalenessSeconds = undefined;
|
|
99
|
+
|
|
100
|
+
options = options ?? {};
|
|
101
|
+
if (options.maxStalenessSeconds != null) {
|
|
102
|
+
if (options.maxStalenessSeconds <= 0) {
|
|
103
|
+
throw new MongoInvalidArgumentError('maxStalenessSeconds must be a positive integer');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.maxStalenessSeconds = options.maxStalenessSeconds;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (this.mode === ReadPreference.PRIMARY) {
|
|
110
|
+
if (this.tags && Array.isArray(this.tags) && this.tags.length > 0) {
|
|
111
|
+
throw new MongoInvalidArgumentError('Primary read preference cannot be combined with tags');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this.maxStalenessSeconds) {
|
|
115
|
+
throw new MongoInvalidArgumentError(
|
|
116
|
+
'Primary read preference cannot be combined with maxStalenessSeconds'
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (this.hedge) {
|
|
121
|
+
throw new MongoInvalidArgumentError(
|
|
122
|
+
'Primary read preference cannot be combined with hedge'
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Support the deprecated `preference` property introduced in the porcelain layer
|
|
129
|
+
get preference(): ReadPreferenceMode {
|
|
130
|
+
return this.mode;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static fromString(mode: string): ReadPreference {
|
|
134
|
+
return new ReadPreference(mode as ReadPreferenceMode);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Construct a ReadPreference given an options object.
|
|
139
|
+
*
|
|
140
|
+
* @param options - The options object from which to extract the read preference.
|
|
141
|
+
*/
|
|
142
|
+
static fromOptions(options?: ReadPreferenceFromOptions): ReadPreference | undefined {
|
|
143
|
+
if (!options) return;
|
|
144
|
+
const readPreference =
|
|
145
|
+
options.readPreference ?? options.session?.transaction.options.readPreference;
|
|
146
|
+
const readPreferenceTags = options.readPreferenceTags;
|
|
147
|
+
|
|
148
|
+
if (readPreference == null) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (typeof readPreference === 'string') {
|
|
153
|
+
return new ReadPreference(readPreference, readPreferenceTags, {
|
|
154
|
+
maxStalenessSeconds: options.maxStalenessSeconds,
|
|
155
|
+
hedge: options.hedge
|
|
156
|
+
});
|
|
157
|
+
} else if (!(readPreference instanceof ReadPreference) && typeof readPreference === 'object') {
|
|
158
|
+
const mode = readPreference.mode || readPreference.preference;
|
|
159
|
+
if (mode && typeof mode === 'string') {
|
|
160
|
+
return new ReadPreference(mode, readPreference.tags ?? readPreferenceTags, {
|
|
161
|
+
maxStalenessSeconds: readPreference.maxStalenessSeconds,
|
|
162
|
+
hedge: options.hedge
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (readPreferenceTags) {
|
|
168
|
+
readPreference.tags = readPreferenceTags;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return readPreference as ReadPreference;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Replaces options.readPreference with a ReadPreference instance
|
|
176
|
+
*/
|
|
177
|
+
static translate(options: ReadPreferenceLikeOptions): ReadPreferenceLikeOptions {
|
|
178
|
+
if (options.readPreference == null) return options;
|
|
179
|
+
const r = options.readPreference;
|
|
180
|
+
|
|
181
|
+
if (typeof r === 'string') {
|
|
182
|
+
options.readPreference = new ReadPreference(r);
|
|
183
|
+
} else if (r && !(r instanceof ReadPreference) && typeof r === 'object') {
|
|
184
|
+
const mode = r.mode || r.preference;
|
|
185
|
+
if (mode && typeof mode === 'string') {
|
|
186
|
+
options.readPreference = new ReadPreference(mode, r.tags, {
|
|
187
|
+
maxStalenessSeconds: r.maxStalenessSeconds
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
} else if (!(r instanceof ReadPreference)) {
|
|
191
|
+
throw new MongoInvalidArgumentError(`Invalid read preference: ${r}`);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return options;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Validate if a mode is legal
|
|
199
|
+
*
|
|
200
|
+
* @param mode - The string representing the read preference mode.
|
|
201
|
+
*/
|
|
202
|
+
static isValid(mode: string): boolean {
|
|
203
|
+
const VALID_MODES = new Set([
|
|
204
|
+
ReadPreference.PRIMARY,
|
|
205
|
+
ReadPreference.PRIMARY_PREFERRED,
|
|
206
|
+
ReadPreference.SECONDARY,
|
|
207
|
+
ReadPreference.SECONDARY_PREFERRED,
|
|
208
|
+
ReadPreference.NEAREST,
|
|
209
|
+
null
|
|
210
|
+
]);
|
|
211
|
+
|
|
212
|
+
return VALID_MODES.has(mode as ReadPreferenceMode);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Validate if a mode is legal
|
|
217
|
+
*
|
|
218
|
+
* @param mode - The string representing the read preference mode.
|
|
219
|
+
*/
|
|
220
|
+
isValid(mode?: string): boolean {
|
|
221
|
+
return ReadPreference.isValid(typeof mode === 'string' ? mode : this.mode);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire
|
|
226
|
+
* @see https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/#op-query
|
|
227
|
+
*/
|
|
228
|
+
secondaryOk(): boolean {
|
|
229
|
+
const NEEDS_SECONDARYOK = new Set<string>([
|
|
230
|
+
ReadPreference.PRIMARY_PREFERRED,
|
|
231
|
+
ReadPreference.SECONDARY,
|
|
232
|
+
ReadPreference.SECONDARY_PREFERRED,
|
|
233
|
+
ReadPreference.NEAREST
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
return NEEDS_SECONDARYOK.has(this.mode);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Check if the two ReadPreferences are equivalent
|
|
241
|
+
*
|
|
242
|
+
* @param readPreference - The read preference with which to check equality
|
|
243
|
+
*/
|
|
244
|
+
equals(readPreference: ReadPreference): boolean {
|
|
245
|
+
return readPreference.mode === this.mode;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Return JSON representation */
|
|
249
|
+
toJSON(): Document {
|
|
250
|
+
const readPreference = { mode: this.mode } as Document;
|
|
251
|
+
if (Array.isArray(this.tags)) readPreference.tags = this.tags;
|
|
252
|
+
if (this.maxStalenessSeconds) readPreference.maxStalenessSeconds = this.maxStalenessSeconds;
|
|
253
|
+
if (this.hedge) readPreference.hedge = this.hedge;
|
|
254
|
+
return readPreference;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Binary, Long, Timestamp } from '../bson';
|
|
2
|
+
import type { ClientSession } from '../sessions';
|
|
3
|
+
import type { Topology } from './topology';
|
|
4
|
+
|
|
5
|
+
// shared state names
|
|
6
|
+
export const STATE_CLOSING = 'closing';
|
|
7
|
+
export const STATE_CLOSED = 'closed';
|
|
8
|
+
export const STATE_CONNECTING = 'connecting';
|
|
9
|
+
export const STATE_CONNECTED = 'connected';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An enumeration of topology types we know about
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export const TopologyType = Object.freeze({
|
|
16
|
+
Single: 'Single',
|
|
17
|
+
ReplicaSetNoPrimary: 'ReplicaSetNoPrimary',
|
|
18
|
+
ReplicaSetWithPrimary: 'ReplicaSetWithPrimary',
|
|
19
|
+
Sharded: 'Sharded',
|
|
20
|
+
Unknown: 'Unknown',
|
|
21
|
+
LoadBalanced: 'LoadBalanced'
|
|
22
|
+
} as const);
|
|
23
|
+
|
|
24
|
+
/** @public */
|
|
25
|
+
export type TopologyType = (typeof TopologyType)[keyof typeof TopologyType];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An enumeration of server types we know about
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export const ServerType = Object.freeze({
|
|
32
|
+
Standalone: 'Standalone',
|
|
33
|
+
Mongos: 'Mongos',
|
|
34
|
+
PossiblePrimary: 'PossiblePrimary',
|
|
35
|
+
RSPrimary: 'RSPrimary',
|
|
36
|
+
RSSecondary: 'RSSecondary',
|
|
37
|
+
RSArbiter: 'RSArbiter',
|
|
38
|
+
RSOther: 'RSOther',
|
|
39
|
+
RSGhost: 'RSGhost',
|
|
40
|
+
Unknown: 'Unknown',
|
|
41
|
+
LoadBalancer: 'LoadBalancer'
|
|
42
|
+
} as const);
|
|
43
|
+
|
|
44
|
+
/** @public */
|
|
45
|
+
export type ServerType = (typeof ServerType)[keyof typeof ServerType];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @public
|
|
49
|
+
* Gossiped in component for the cluster time tracking the state of user databases
|
|
50
|
+
* across the cluster. It may optionally include a signature identifying the process that
|
|
51
|
+
* generated such a value.
|
|
52
|
+
*/
|
|
53
|
+
export interface ClusterTime {
|
|
54
|
+
clusterTime: Timestamp;
|
|
55
|
+
/** Used to validate the identity of a request or response's ClusterTime. */
|
|
56
|
+
signature?: {
|
|
57
|
+
hash: Binary;
|
|
58
|
+
keyId: Long;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Shared function to determine clusterTime for a given topology or session */
|
|
63
|
+
export function _advanceClusterTime(
|
|
64
|
+
entity: Topology | ClientSession,
|
|
65
|
+
$clusterTime: ClusterTime
|
|
66
|
+
): void {
|
|
67
|
+
if (entity.clusterTime == null) {
|
|
68
|
+
entity.clusterTime = $clusterTime;
|
|
69
|
+
} else {
|
|
70
|
+
if ($clusterTime.clusterTime.greaterThan(entity.clusterTime.clusterTime)) {
|
|
71
|
+
entity.clusterTime = $clusterTime;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { Document } from '../bson';
|
|
2
|
+
import {
|
|
3
|
+
SERVER_CLOSED,
|
|
4
|
+
SERVER_DESCRIPTION_CHANGED,
|
|
5
|
+
SERVER_HEARTBEAT_FAILED,
|
|
6
|
+
SERVER_HEARTBEAT_STARTED,
|
|
7
|
+
SERVER_HEARTBEAT_SUCCEEDED,
|
|
8
|
+
SERVER_OPENING,
|
|
9
|
+
TOPOLOGY_CLOSED,
|
|
10
|
+
TOPOLOGY_DESCRIPTION_CHANGED,
|
|
11
|
+
TOPOLOGY_OPENING
|
|
12
|
+
} from '../constants';
|
|
13
|
+
import type { ServerDescription } from './server_description';
|
|
14
|
+
import type { TopologyDescription } from './topology_description';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Emitted when server description changes, but does NOT include changes to the RTT.
|
|
18
|
+
* @public
|
|
19
|
+
* @category Event
|
|
20
|
+
*/
|
|
21
|
+
export class ServerDescriptionChangedEvent {
|
|
22
|
+
/** A unique identifier for the topology */
|
|
23
|
+
topologyId: number;
|
|
24
|
+
/** The address (host/port pair) of the server */
|
|
25
|
+
address: string;
|
|
26
|
+
/** The previous server description */
|
|
27
|
+
previousDescription: ServerDescription;
|
|
28
|
+
/** The new server description */
|
|
29
|
+
newDescription: ServerDescription;
|
|
30
|
+
name = SERVER_DESCRIPTION_CHANGED;
|
|
31
|
+
|
|
32
|
+
/** @internal */
|
|
33
|
+
constructor(
|
|
34
|
+
topologyId: number,
|
|
35
|
+
address: string,
|
|
36
|
+
previousDescription: ServerDescription,
|
|
37
|
+
newDescription: ServerDescription
|
|
38
|
+
) {
|
|
39
|
+
this.topologyId = topologyId;
|
|
40
|
+
this.address = address;
|
|
41
|
+
this.previousDescription = previousDescription;
|
|
42
|
+
this.newDescription = newDescription;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Emitted when server is initialized.
|
|
48
|
+
* @public
|
|
49
|
+
* @category Event
|
|
50
|
+
*/
|
|
51
|
+
export class ServerOpeningEvent {
|
|
52
|
+
/** A unique identifier for the topology */
|
|
53
|
+
topologyId: number;
|
|
54
|
+
/** The address (host/port pair) of the server */
|
|
55
|
+
address: string;
|
|
56
|
+
/** @internal */
|
|
57
|
+
name = SERVER_OPENING;
|
|
58
|
+
|
|
59
|
+
/** @internal */
|
|
60
|
+
constructor(topologyId: number, address: string) {
|
|
61
|
+
this.topologyId = topologyId;
|
|
62
|
+
this.address = address;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Emitted when server is closed.
|
|
68
|
+
* @public
|
|
69
|
+
* @category Event
|
|
70
|
+
*/
|
|
71
|
+
export class ServerClosedEvent {
|
|
72
|
+
/** A unique identifier for the topology */
|
|
73
|
+
topologyId: number;
|
|
74
|
+
/** The address (host/port pair) of the server */
|
|
75
|
+
address: string;
|
|
76
|
+
/** @internal */
|
|
77
|
+
name = SERVER_CLOSED;
|
|
78
|
+
|
|
79
|
+
/** @internal */
|
|
80
|
+
constructor(topologyId: number, address: string) {
|
|
81
|
+
this.topologyId = topologyId;
|
|
82
|
+
this.address = address;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Emitted when topology description changes.
|
|
88
|
+
* @public
|
|
89
|
+
* @category Event
|
|
90
|
+
*/
|
|
91
|
+
export class TopologyDescriptionChangedEvent {
|
|
92
|
+
/** A unique identifier for the topology */
|
|
93
|
+
topologyId: number;
|
|
94
|
+
/** The old topology description */
|
|
95
|
+
previousDescription: TopologyDescription;
|
|
96
|
+
/** The new topology description */
|
|
97
|
+
newDescription: TopologyDescription;
|
|
98
|
+
/** @internal */
|
|
99
|
+
name = TOPOLOGY_DESCRIPTION_CHANGED;
|
|
100
|
+
|
|
101
|
+
/** @internal */
|
|
102
|
+
constructor(
|
|
103
|
+
topologyId: number,
|
|
104
|
+
previousDescription: TopologyDescription,
|
|
105
|
+
newDescription: TopologyDescription
|
|
106
|
+
) {
|
|
107
|
+
this.topologyId = topologyId;
|
|
108
|
+
this.previousDescription = previousDescription;
|
|
109
|
+
this.newDescription = newDescription;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Emitted when topology is initialized.
|
|
115
|
+
* @public
|
|
116
|
+
* @category Event
|
|
117
|
+
*/
|
|
118
|
+
export class TopologyOpeningEvent {
|
|
119
|
+
/** A unique identifier for the topology */
|
|
120
|
+
topologyId: number;
|
|
121
|
+
/** @internal */
|
|
122
|
+
name = TOPOLOGY_OPENING;
|
|
123
|
+
|
|
124
|
+
/** @internal */
|
|
125
|
+
constructor(topologyId: number) {
|
|
126
|
+
this.topologyId = topologyId;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Emitted when topology is closed.
|
|
132
|
+
* @public
|
|
133
|
+
* @category Event
|
|
134
|
+
*/
|
|
135
|
+
export class TopologyClosedEvent {
|
|
136
|
+
/** A unique identifier for the topology */
|
|
137
|
+
topologyId: number;
|
|
138
|
+
/** @internal */
|
|
139
|
+
name = TOPOLOGY_CLOSED;
|
|
140
|
+
|
|
141
|
+
/** @internal */
|
|
142
|
+
constructor(topologyId: number) {
|
|
143
|
+
this.topologyId = topologyId;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Emitted when the server monitor’s hello command is started - immediately before
|
|
149
|
+
* the hello command is serialized into raw BSON and written to the socket.
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
* @category Event
|
|
153
|
+
*/
|
|
154
|
+
export class ServerHeartbeatStartedEvent {
|
|
155
|
+
/** The connection id for the command */
|
|
156
|
+
connectionId: string;
|
|
157
|
+
/** Is true when using the streaming protocol */
|
|
158
|
+
awaited: boolean;
|
|
159
|
+
/** @internal */
|
|
160
|
+
name = SERVER_HEARTBEAT_STARTED;
|
|
161
|
+
|
|
162
|
+
/** @internal */
|
|
163
|
+
constructor(connectionId: string, awaited: boolean) {
|
|
164
|
+
this.connectionId = connectionId;
|
|
165
|
+
this.awaited = awaited;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Emitted when the server monitor’s hello succeeds.
|
|
171
|
+
* @public
|
|
172
|
+
* @category Event
|
|
173
|
+
*/
|
|
174
|
+
export class ServerHeartbeatSucceededEvent {
|
|
175
|
+
/** The connection id for the command */
|
|
176
|
+
connectionId: string;
|
|
177
|
+
/** The execution time of the event in ms */
|
|
178
|
+
duration: number;
|
|
179
|
+
/** The command reply */
|
|
180
|
+
reply: Document;
|
|
181
|
+
/** Is true when using the streaming protocol */
|
|
182
|
+
awaited: boolean;
|
|
183
|
+
/** @internal */
|
|
184
|
+
name = SERVER_HEARTBEAT_SUCCEEDED;
|
|
185
|
+
|
|
186
|
+
/** @internal */
|
|
187
|
+
constructor(connectionId: string, duration: number, reply: Document | null, awaited: boolean) {
|
|
188
|
+
this.connectionId = connectionId;
|
|
189
|
+
this.duration = duration;
|
|
190
|
+
this.reply = reply ?? {};
|
|
191
|
+
this.awaited = awaited;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Emitted when the server monitor’s hello fails, either with an “ok: 0” or a socket exception.
|
|
197
|
+
* @public
|
|
198
|
+
* @category Event
|
|
199
|
+
*/
|
|
200
|
+
export class ServerHeartbeatFailedEvent {
|
|
201
|
+
/** The connection id for the command */
|
|
202
|
+
connectionId: string;
|
|
203
|
+
/** The execution time of the event in ms */
|
|
204
|
+
duration: number;
|
|
205
|
+
/** The command failure */
|
|
206
|
+
failure: Error;
|
|
207
|
+
/** Is true when using the streaming protocol */
|
|
208
|
+
awaited: boolean;
|
|
209
|
+
/** @internal */
|
|
210
|
+
name = SERVER_HEARTBEAT_FAILED;
|
|
211
|
+
|
|
212
|
+
/** @internal */
|
|
213
|
+
constructor(connectionId: string, duration: number, failure: Error, awaited: boolean) {
|
|
214
|
+
this.connectionId = connectionId;
|
|
215
|
+
this.duration = duration;
|
|
216
|
+
this.failure = failure;
|
|
217
|
+
this.awaited = awaited;
|
|
218
|
+
}
|
|
219
|
+
}
|