mongo 2.19.1 → 2.21.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.
- checksums.yaml +4 -4
- data/README.md +40 -1
- data/Rakefile +83 -174
- data/lib/mongo/address.rb +22 -3
- data/lib/mongo/auth/aws/credentials_retriever.rb +70 -17
- data/lib/mongo/auth/base.rb +1 -1
- data/lib/mongo/bulk_write.rb +35 -2
- data/lib/mongo/client.rb +38 -6
- data/lib/mongo/client_encryption.rb +6 -3
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +6 -1
- data/lib/mongo/cluster/sdam_flow.rb +20 -7
- data/lib/mongo/cluster/topology/base.rb +16 -0
- data/lib/mongo/cluster.rb +41 -5
- data/lib/mongo/collection/helpers.rb +1 -1
- data/lib/mongo/collection/view/aggregation/behavior.rb +131 -0
- data/lib/mongo/collection/view/aggregation.rb +33 -99
- data/lib/mongo/collection/view/builder/aggregation.rb +1 -7
- data/lib/mongo/collection/view/change_stream.rb +80 -27
- data/lib/mongo/collection/view/iterable.rb +92 -60
- data/lib/mongo/collection/view/map_reduce.rb +25 -8
- data/lib/mongo/collection/view/readable.rb +79 -30
- data/lib/mongo/collection/view/writable.rb +109 -48
- data/lib/mongo/collection/view.rb +44 -3
- data/lib/mongo/collection.rb +185 -26
- data/lib/mongo/config.rb +2 -2
- data/lib/mongo/crypt/auto_encrypter.rb +4 -6
- data/lib/mongo/crypt/binding.rb +4 -4
- data/lib/mongo/crypt/context.rb +20 -14
- data/lib/mongo/crypt/encryption_io.rb +56 -26
- data/lib/mongo/crypt/explicit_encrypter.rb +49 -20
- data/lib/mongo/crypt/explicit_encryption_context.rb +17 -11
- data/lib/mongo/crypt/kms/azure/credentials_retriever.rb +22 -6
- data/lib/mongo/crypt/kms/gcp/credentials_retriever.rb +29 -4
- data/lib/mongo/csot_timeout_holder.rb +119 -0
- data/lib/mongo/cursor/kill_spec.rb +5 -2
- data/lib/mongo/cursor/nontailable.rb +27 -0
- data/lib/mongo/cursor.rb +86 -24
- data/lib/mongo/cursor_host.rb +82 -0
- data/lib/mongo/database/view.rb +81 -14
- data/lib/mongo/database.rb +88 -18
- data/lib/mongo/error/operation_failure.rb +209 -204
- data/lib/mongo/error/server_timeout_error.rb +12 -0
- data/lib/mongo/error/socket_timeout_error.rb +3 -1
- data/lib/mongo/error/timeout_error.rb +23 -0
- data/lib/mongo/error/transactions_not_supported.rb +34 -0
- data/lib/mongo/error.rb +3 -0
- data/lib/mongo/grid/fs_bucket.rb +48 -9
- data/lib/mongo/grid/stream/read.rb +15 -1
- data/lib/mongo/grid/stream/write.rb +21 -4
- data/lib/mongo/index/view.rb +77 -16
- data/lib/mongo/monitoring/event/secure.rb +1 -1
- data/lib/mongo/operation/context.rb +40 -2
- data/lib/mongo/operation/create_search_indexes/op_msg.rb +31 -0
- data/lib/mongo/operation/create_search_indexes.rb +15 -0
- data/lib/mongo/operation/delete/op_msg.rb +2 -1
- data/lib/mongo/operation/drop_search_index/op_msg.rb +33 -0
- data/lib/mongo/operation/drop_search_index.rb +15 -0
- data/lib/mongo/operation/find/op_msg.rb +45 -0
- data/lib/mongo/operation/get_more/op_msg.rb +33 -0
- data/lib/mongo/operation/insert/op_msg.rb +3 -2
- data/lib/mongo/operation/insert/result.rb +4 -2
- data/lib/mongo/operation/list_collections/result.rb +1 -1
- data/lib/mongo/operation/map_reduce/result.rb +1 -1
- data/lib/mongo/operation/op_msg_base.rb +3 -1
- data/lib/mongo/operation/result.rb +26 -5
- data/lib/mongo/operation/shared/executable.rb +55 -28
- data/lib/mongo/operation/shared/op_msg_executable.rb +4 -1
- data/lib/mongo/operation/shared/response_handling.rb +25 -27
- data/lib/mongo/operation/shared/sessions_supported.rb +1 -1
- data/lib/mongo/operation/shared/specifiable.rb +7 -0
- data/lib/mongo/operation/shared/timed.rb +52 -0
- data/lib/mongo/operation/shared/write.rb +4 -1
- data/lib/mongo/operation/update/op_msg.rb +2 -1
- data/lib/mongo/operation/update_search_index/op_msg.rb +34 -0
- data/lib/mongo/operation/update_search_index.rb +15 -0
- data/lib/mongo/operation.rb +4 -0
- data/lib/mongo/protocol/message.rb +1 -4
- data/lib/mongo/protocol/msg.rb +2 -2
- data/lib/mongo/retryable/base_worker.rb +28 -3
- data/lib/mongo/retryable/read_worker.rb +78 -36
- data/lib/mongo/retryable/write_worker.rb +59 -25
- data/lib/mongo/retryable.rb +8 -2
- data/lib/mongo/search_index/view.rb +232 -0
- data/lib/mongo/server/app_metadata/environment.rb +64 -9
- data/lib/mongo/server/app_metadata.rb +5 -4
- data/lib/mongo/server/connection.rb +11 -5
- data/lib/mongo/server/connection_base.rb +22 -2
- data/lib/mongo/server/connection_pool.rb +32 -14
- data/lib/mongo/server/description/features.rb +2 -1
- data/lib/mongo/server/description.rb +18 -5
- data/lib/mongo/server/monitor.rb +7 -4
- data/lib/mongo/server/pending_connection.rb +25 -8
- data/lib/mongo/server/{round_trip_time_averager.rb → round_trip_time_calculator.rb} +25 -7
- data/lib/mongo/server.rb +11 -6
- data/lib/mongo/server_selector/base.rb +54 -12
- data/lib/mongo/session/server_session/dirtyable.rb +52 -0
- data/lib/mongo/session/server_session.rb +3 -0
- data/lib/mongo/session/session_pool.rb +12 -18
- data/lib/mongo/session.rb +110 -9
- data/lib/mongo/socket/ssl.rb +131 -18
- data/lib/mongo/socket/tcp.rb +40 -6
- data/lib/mongo/socket.rb +154 -25
- data/lib/mongo/uri/options_mapper.rb +1 -0
- data/lib/mongo/uri.rb +0 -4
- data/lib/mongo/version.rb +1 -5
- data/lib/mongo.rb +2 -0
- data/mongo.gemspec +9 -18
- data/spec/atlas/atlas_connectivity_spec.rb +9 -9
- data/spec/atlas/operations_spec.rb +5 -5
- data/spec/faas/ruby-sam-app/Gemfile +9 -0
- data/spec/faas/ruby-sam-app/mongodb/Gemfile +4 -0
- data/spec/faas/ruby-sam-app/mongodb/app.rb +149 -0
- data/spec/faas/ruby-sam-app/template.yaml +48 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +2 -1
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +494 -487
- data/spec/integration/client_side_encryption/corpus_spec.rb +10 -2
- data/spec/integration/client_side_encryption/on_demand_aws_credentials_spec.rb +1 -1
- data/spec/integration/client_side_encryption/range_explicit_encryption_prose_spec.rb +67 -20
- data/spec/integration/client_side_operations_timeout/encryption_prose_spec.rb +131 -0
- data/spec/integration/connection_pool_populator_spec.rb +2 -0
- data/spec/integration/cursor_pinning_spec.rb +15 -60
- data/spec/integration/cursor_reaping_spec.rb +1 -1
- data/spec/integration/docs_examples_spec.rb +1 -1
- data/spec/integration/find_options_spec.rb +227 -0
- data/spec/integration/operation_failure_code_spec.rb +1 -1
- data/spec/integration/operation_failure_message_spec.rb +3 -3
- data/spec/integration/retryable_errors_spec.rb +2 -2
- data/spec/integration/retryable_reads_errors_spec.rb +196 -31
- data/spec/integration/retryable_writes_errors_spec.rb +156 -0
- data/spec/integration/sdam_error_handling_spec.rb +4 -1
- data/spec/integration/search_indexes_prose_spec.rb +172 -0
- data/spec/integration/server_spec.rb +4 -3
- data/spec/integration/transactions_api_examples_spec.rb +2 -0
- data/spec/kerberos/kerberos_spec.rb +4 -0
- data/spec/lite_spec_helper.rb +34 -20
- data/spec/mongo/auth/user/view_spec.rb +1 -1
- data/spec/mongo/caching_cursor_spec.rb +1 -1
- data/spec/mongo/client_encryption_spec.rb +1 -0
- data/spec/mongo/client_spec.rb +158 -4
- data/spec/mongo/cluster_spec.rb +36 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +20 -40
- data/spec/mongo/collection/view/change_stream_spec.rb +3 -3
- data/spec/mongo/collection/view/explainable_spec.rb +2 -0
- data/spec/mongo/collection_crud_spec.rb +2 -1
- data/spec/mongo/collection_spec.rb +5 -6
- data/spec/mongo/crypt/auto_encrypter_spec.rb +14 -12
- data/spec/mongo/crypt/data_key_context_spec.rb +3 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +2 -2
- data/spec/mongo/crypt/handle_spec.rb +1 -1
- data/spec/mongo/cursor_spec.rb +26 -9
- data/spec/mongo/error/operation_failure_heavy_spec.rb +2 -2
- data/spec/mongo/operation/context_spec.rb +79 -0
- data/spec/mongo/operation/create/op_msg_spec.rb +106 -110
- data/spec/mongo/operation/delete/op_msg_spec.rb +6 -5
- data/spec/mongo/operation/find/op_msg_spec.rb +66 -0
- data/spec/mongo/operation/get_more/op_msg_spec.rb +65 -0
- data/spec/mongo/operation/insert/op_msg_spec.rb +128 -131
- data/spec/mongo/operation/insert_spec.rb +1 -1
- data/spec/mongo/operation/shared/csot/examples.rb +113 -0
- data/spec/mongo/query_cache_spec.rb +243 -225
- data/spec/mongo/retryable/write_worker_spec.rb +39 -0
- data/spec/mongo/retryable_spec.rb +1 -0
- data/spec/mongo/server/app_metadata/environment_spec.rb +135 -0
- data/spec/mongo/server/app_metadata_spec.rb +12 -2
- data/spec/mongo/server/connection_spec.rb +26 -0
- data/spec/mongo/server/round_trip_time_calculator_spec.rb +120 -0
- data/spec/mongo/session/session_pool_spec.rb +1 -16
- data/spec/mongo/session_transaction_spec.rb +15 -0
- data/spec/mongo/socket/ssl_spec.rb +0 -10
- data/spec/mongo/uri_spec.rb +0 -9
- data/spec/runners/change_streams/test.rb +2 -2
- data/spec/runners/crud/operation.rb +1 -1
- data/spec/runners/crud/test.rb +0 -8
- data/spec/runners/crud/verifier.rb +3 -1
- data/spec/runners/crud.rb +1 -1
- data/spec/runners/transactions/operation.rb +4 -6
- data/spec/runners/transactions/test.rb +12 -3
- data/spec/runners/unified/ambiguous_operations.rb +13 -0
- data/spec/runners/unified/assertions.rb +20 -3
- data/spec/runners/unified/change_stream_operations.rb +14 -24
- data/spec/runners/unified/crud_operations.rb +82 -47
- data/spec/runners/unified/ddl_operations.rb +38 -7
- data/spec/runners/unified/grid_fs_operations.rb +37 -2
- data/spec/runners/unified/search_index_operations.rb +63 -0
- data/spec/runners/unified/support_operations.rb +46 -9
- data/spec/runners/unified/test.rb +33 -12
- data/spec/runners/unified.rb +1 -1
- data/spec/solo/clean_exit_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/spec_tests/client_side_operations_timeout_spec.rb +15 -0
- data/spec/spec_tests/data/change_streams_unified/change-streams-clusterTime.yml +3 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-disambiguatedPaths.yml +3 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-errors.yml +3 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-pre_and_post_images.yml +1 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-resume-allowlist.yml +1 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-resume-errorLabels.yml +1 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +1 -1
- data/spec/spec_tests/data/client_side_encryption/badQueries.yml +2 -1
- data/spec/spec_tests/data/client_side_encryption/explain.yml +2 -2
- data/spec/spec_tests/data/client_side_encryption/fle2v2-BypassQueryAnalysis.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Compact.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-CreateCollection.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-DecryptExistingData.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFields-vs-jsonSchema.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFieldsMap-defaults.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-InsertFind-Indexed.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-InsertFind-Unindexed.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-MissingKey.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-NoEncryption.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-validatorAndPartialFieldExpression.yml +2 -1
- data/spec/spec_tests/data/client_side_encryption/timeoutMS.yml +67 -0
- data/spec/spec_tests/data/client_side_operations_timeout/bulkWrite.yml +87 -0
- data/spec/spec_tests/data/client_side_operations_timeout/change-streams.yml +358 -0
- data/spec/spec_tests/data/client_side_operations_timeout/close-cursors.yml +129 -0
- data/spec/spec_tests/data/client_side_operations_timeout/command-execution.yml +250 -0
- data/spec/spec_tests/data/client_side_operations_timeout/convenient-transactions.yml +113 -0
- data/spec/spec_tests/data/client_side_operations_timeout/cursors.yml +70 -0
- data/spec/spec_tests/data/client_side_operations_timeout/deprecated-options.yml +3982 -0
- data/spec/spec_tests/data/client_side_operations_timeout/error-transformations.yml +96 -0
- data/spec/spec_tests/data/client_side_operations_timeout/global-timeoutMS.yml +3236 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-advanced.yml +207 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-delete.yml +152 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-download.yml +182 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-find.yml +100 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-upload.yml +249 -0
- data/spec/spec_tests/data/client_side_operations_timeout/legacy-timeouts.yml +204 -0
- data/spec/spec_tests/data/client_side_operations_timeout/non-tailable-cursors.yml +307 -0
- data/spec/spec_tests/data/client_side_operations_timeout/override-collection-timeoutMS.yml +1877 -0
- data/spec/spec_tests/data/client_side_operations_timeout/override-operation-timeoutMS.yml +1918 -0
- data/spec/spec_tests/data/client_side_operations_timeout/retryability-legacy-timeouts.yml +1676 -0
- data/spec/spec_tests/data/client_side_operations_timeout/retryability-timeoutMS.yml +2824 -0
- data/spec/spec_tests/data/client_side_operations_timeout/sessions-inherit-timeoutMS.yml +168 -0
- data/spec/spec_tests/data/client_side_operations_timeout/sessions-override-operation-timeoutMS.yml +171 -0
- data/spec/spec_tests/data/client_side_operations_timeout/sessions-override-timeoutMS.yml +168 -0
- data/spec/spec_tests/data/client_side_operations_timeout/tailable-awaitData.yml +247 -0
- data/spec/spec_tests/data/client_side_operations_timeout/tailable-non-awaitData.yml +181 -0
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +0 -10
- data/spec/spec_tests/data/connection_string/valid-options.yml +13 -0
- data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +6 -0
- data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +6 -0
- data/spec/spec_tests/data/crud_unified/find-test-all-options.yml +377 -0
- data/spec/spec_tests/data/index_management/createSearchIndex.yml +64 -0
- data/spec/spec_tests/data/index_management/createSearchIndexes.yml +86 -0
- data/spec/spec_tests/data/index_management/dropSearchIndex.yml +43 -0
- data/spec/spec_tests/data/index_management/listSearchIndexes.yml +91 -0
- data/spec/spec_tests/data/index_management/updateSearchIndex.yml +46 -0
- data/spec/spec_tests/data/retryable_writes/unified/bulkWrite-serverErrors.yml +3 -6
- data/spec/spec_tests/data/retryable_writes/unified/insertOne-serverErrors.yml +3 -6
- data/spec/spec_tests/data/run_command_unified/runCommand.yml +319 -0
- data/spec/spec_tests/data/sessions_unified/driver-sessions-dirty-session-errors.yml +351 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-crud.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-writes.yml +7 -7
- data/spec/spec_tests/data/unified/valid-pass/poc-sessions.yml +3 -4
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-convenient-api.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-mongos-pin-auto.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions.yml +3 -3
- data/spec/spec_tests/index_management_unified_spec.rb +13 -0
- data/spec/spec_tests/run_command_unified_spec.rb +13 -0
- data/spec/spec_tests/sdam_unified_spec.rb +2 -0
- data/spec/spec_tests/server_selection_rtt_spec.rb +6 -6
- data/spec/spec_tests/transactions_unified_spec.rb +2 -1
- data/spec/support/certificates/atlas-ocsp-ca.crt +89 -79
- data/spec/support/certificates/atlas-ocsp.crt +117 -122
- data/spec/support/certificates/retrieve-atlas-cert +1 -1
- data/spec/support/cluster_tools.rb +3 -3
- data/spec/support/common_shortcuts.rb +2 -2
- data/spec/support/constraints.rb +6 -0
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-Date.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DecimalNoPrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DecimalPrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DoubleNoPrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DoublePrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-Int.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-Long.json +1 -1
- data/spec/support/ocsp +1 -1
- data/spec/support/recording_logger.rb +27 -0
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +5 -0
- data/spec/support/spec_setup.rb +2 -2
- data/spec/support/utils.rb +3 -1
- metadata +1329 -1368
- checksums.yaml.gz.sig +0 -0
- data/spec/mongo/server/round_trip_time_averager_spec.rb +0 -48
- data/spec/shared/LICENSE +0 -20
- data/spec/shared/bin/get-mongodb-download-url +0 -17
- data/spec/shared/bin/s3-copy +0 -45
- data/spec/shared/bin/s3-upload +0 -69
- data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
- data/spec/shared/lib/mrss/cluster_config.rb +0 -231
- data/spec/shared/lib/mrss/constraints.rb +0 -378
- data/spec/shared/lib/mrss/docker_runner.rb +0 -295
- data/spec/shared/lib/mrss/eg_config_utils.rb +0 -51
- data/spec/shared/lib/mrss/event_subscriber.rb +0 -210
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -238
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -113
- data/spec/shared/lib/mrss/session_registry.rb +0 -69
- data/spec/shared/lib/mrss/session_registry_legacy.rb +0 -60
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -179
- data/spec/shared/lib/mrss/utils.rb +0 -37
- data/spec/shared/share/Dockerfile.erb +0 -330
- data/spec/shared/share/haproxy-1.conf +0 -16
- data/spec/shared/share/haproxy-2.conf +0 -17
- data/spec/shared/shlib/config.sh +0 -27
- data/spec/shared/shlib/distro.sh +0 -74
- data/spec/shared/shlib/server.sh +0 -416
- data/spec/shared/shlib/set_env.sh +0 -169
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Aggregate.yml +0 -241
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Correctness.yml +0 -422
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Delete.yml +0 -182
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-FindOneAndUpdate.yml +0 -239
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-InsertFind.yml +0 -235
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Update.yml +0 -252
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Aggregate.yml +0 -1687
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Correctness.yml +0 -293
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Delete.yml +0 -905
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-FindOneAndUpdate.yml +0 -1684
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-InsertFind.yml +0 -1680
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Update.yml +0 -1697
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Aggregate.yml +0 -329
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Correctness.yml +0 -424
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Delete.yml +0 -226
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.yml +0 -327
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-InsertFind.yml +0 -319
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Update.yml +0 -336
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Aggregate.yml +0 -913
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Correctness.yml +0 -292
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Delete.yml +0 -518
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-FindOneAndUpdate.yml +0 -911
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-InsertFind.yml +0 -907
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Update.yml +0 -924
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Aggregate.yml +0 -325
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Correctness.yml +0 -424
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Delete.yml +0 -224
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-FindOneAndUpdate.yml +0 -323
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-InsertFind.yml +0 -319
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Update.yml +0 -338
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Aggregate.yml +0 -241
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Correctness.yml +0 -423
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Delete.yml +0 -182
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-FindOneAndUpdate.yml +0 -239
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-InsertFind.yml +0 -235
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Update.yml +0 -254
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Aggregate.yml +0 -241
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Correctness.yml +0 -422
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Delete.yml +0 -182
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-FindOneAndUpdate.yml +0 -239
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-InsertFind.yml +0 -235
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Update.yml +0 -254
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-WrongType.yml +0 -43
- data/spec/spec_tests/data/cmap/pool-clear-interrupt-immediately.yml +0 -49
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
|
@@ -63,10 +63,10 @@ module Mongo
|
|
|
63
63
|
:client,
|
|
64
64
|
:cluster,
|
|
65
65
|
:database,
|
|
66
|
+
:nro_write_with_retry,
|
|
66
67
|
:read_with_retry,
|
|
67
68
|
:read_with_retry_cursor,
|
|
68
69
|
:write_with_retry,
|
|
69
|
-
:nro_write_with_retry,
|
|
70
70
|
:write_concern_with_session
|
|
71
71
|
|
|
72
72
|
# Delegate to the cluster for the next primary.
|
|
@@ -74,6 +74,12 @@ module Mongo
|
|
|
74
74
|
|
|
75
75
|
alias :selector :filter
|
|
76
76
|
|
|
77
|
+
# @return [ Integer | nil | The timeout_ms value that was passed as an
|
|
78
|
+
# option to the view.
|
|
79
|
+
#
|
|
80
|
+
# @api private
|
|
81
|
+
attr_reader :operation_timeout_ms
|
|
82
|
+
|
|
77
83
|
# Compare two +View+ objects.
|
|
78
84
|
#
|
|
79
85
|
# @example Compare the view with another object.
|
|
@@ -127,6 +133,7 @@ module Mongo
|
|
|
127
133
|
# return in each response from MongoDB.
|
|
128
134
|
# @option options [ Hash ] :collation The collation to use.
|
|
129
135
|
# @option options [ String ] :comment Associate a comment with the query.
|
|
136
|
+
# @option options [ :tailable, :tailable_await ] :cursor_type The type of cursor to use.
|
|
130
137
|
# @option options [ Hash ] :explain Execute an explain with the provided
|
|
131
138
|
# explain options (known options are :verbose and :verbosity) rather
|
|
132
139
|
# than a find.
|
|
@@ -150,15 +157,26 @@ module Mongo
|
|
|
150
157
|
# document more than once. Deprecated as of MongoDB server version 4.0.
|
|
151
158
|
# @option options [ Hash ] :sort The key and direction pairs used to sort
|
|
152
159
|
# the results.
|
|
160
|
+
# @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
|
|
161
|
+
# :timeout_ms (whether it applies to the lifetime of the cursor, or per
|
|
162
|
+
# iteration).
|
|
163
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
164
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
165
|
+
# The default value is unset which means the value is inherited from
|
|
166
|
+
# the collection or the database or the client.
|
|
153
167
|
#
|
|
154
168
|
# @since 2.0.0
|
|
155
169
|
def initialize(collection, filter = {}, options = {})
|
|
156
170
|
validate_doc!(filter)
|
|
157
|
-
@collection = collection
|
|
158
171
|
|
|
159
172
|
filter = BSON::Document.new(filter)
|
|
160
173
|
options = BSON::Document.new(options)
|
|
161
174
|
|
|
175
|
+
@collection = collection
|
|
176
|
+
@operation_timeout_ms = options.delete(:timeout_ms)
|
|
177
|
+
|
|
178
|
+
validate_timeout_mode!(options)
|
|
179
|
+
|
|
162
180
|
# This is when users pass $query in filter and other modifiers
|
|
163
181
|
# alongside?
|
|
164
182
|
query = filter.delete(:$query)
|
|
@@ -170,6 +188,14 @@ module Mongo
|
|
|
170
188
|
@options = Operation::Find::Builder::Modifiers.map_driver_options(modifiers).merge!(options).freeze
|
|
171
189
|
end
|
|
172
190
|
|
|
191
|
+
# The timeout_ms value to use for this operation; either specified as an
|
|
192
|
+
# option to the view, or inherited from the collection.
|
|
193
|
+
#
|
|
194
|
+
# @return [ Integer | nil ] the timeout_ms for this operation
|
|
195
|
+
def timeout_ms
|
|
196
|
+
operation_timeout_ms || collection.timeout_ms
|
|
197
|
+
end
|
|
198
|
+
|
|
173
199
|
# Get a human-readable string representation of +View+.
|
|
174
200
|
#
|
|
175
201
|
# @example Get the inspection.
|
|
@@ -195,6 +221,20 @@ module Mongo
|
|
|
195
221
|
WriteConcern.get(options[:write_concern] || options[:write] || collection.write_concern)
|
|
196
222
|
end
|
|
197
223
|
|
|
224
|
+
# @return [ Hash ] timeout_ms value set on the operation level (if any),
|
|
225
|
+
# and/or timeout_ms that is set on collection/database/client level (if any).
|
|
226
|
+
#
|
|
227
|
+
# @api private
|
|
228
|
+
def operation_timeouts(opts = {})
|
|
229
|
+
{}.tap do |result|
|
|
230
|
+
if opts[:timeout_ms] || operation_timeout_ms
|
|
231
|
+
result[:operation_timeout_ms] = opts[:timeout_ms] || operation_timeout_ms
|
|
232
|
+
else
|
|
233
|
+
result[:inherited_timeout_ms] = collection.timeout_ms
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
198
238
|
private
|
|
199
239
|
|
|
200
240
|
def initialize_copy(other)
|
|
@@ -204,13 +244,14 @@ module Mongo
|
|
|
204
244
|
end
|
|
205
245
|
|
|
206
246
|
def new(options)
|
|
247
|
+
options = options.merge(timeout_ms: operation_timeout_ms) if operation_timeout_ms
|
|
207
248
|
View.new(collection, filter, options)
|
|
208
249
|
end
|
|
209
250
|
|
|
210
251
|
def view; self; end
|
|
211
252
|
|
|
212
253
|
def with_session(opts = {}, &block)
|
|
213
|
-
client.
|
|
254
|
+
client.with_session(@options.merge(opts), &block)
|
|
214
255
|
end
|
|
215
256
|
end
|
|
216
257
|
end
|
data/lib/mongo/collection.rb
CHANGED
|
@@ -134,8 +134,12 @@ module Mongo
|
|
|
134
134
|
# and *:nearest*.
|
|
135
135
|
# - *:tag_sets* -- an array of hashes.
|
|
136
136
|
# - *:local_threshold*.
|
|
137
|
-
# @option
|
|
138
|
-
# @option
|
|
137
|
+
# @option options [ Session ] :session The session to use for the operation.
|
|
138
|
+
# @option options [ Integer ] :size The size of the capped collection.
|
|
139
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
140
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
141
|
+
# The default value is unset which means the value is inherited from
|
|
142
|
+
# the database or the client.
|
|
139
143
|
# @option opts [ Hash ] :time_series Create a time-series collection.
|
|
140
144
|
# The hash may have the following items:
|
|
141
145
|
# - *:timeField* -- The name of the field which contains the date in each
|
|
@@ -163,6 +167,7 @@ module Mongo
|
|
|
163
167
|
@database = database
|
|
164
168
|
@name = name.to_s.freeze
|
|
165
169
|
@options = options.dup
|
|
170
|
+
@timeout_ms = options.delete(:timeout_ms)
|
|
166
171
|
=begin WriteConcern object support
|
|
167
172
|
if @options[:write_concern].is_a?(WriteConcern::Base)
|
|
168
173
|
# Cache the instance so that we do not needlessly reconstruct it.
|
|
@@ -339,7 +344,9 @@ module Mongo
|
|
|
339
344
|
# inserted or updated documents where the clustered index key value
|
|
340
345
|
# matches an existing value in the index.
|
|
341
346
|
# - *:name* -- Optional. A name that uniquely identifies the clustered index.
|
|
342
|
-
# @option opts [ Hash ] :collation The collation to use
|
|
347
|
+
# @option opts [ Hash ] :collation The collation to use when creating the
|
|
348
|
+
# collection. This option will not be sent to the server when calling
|
|
349
|
+
# collection methods.
|
|
343
350
|
# @option opts [ Hash ] :encrypted_fields Hash describing encrypted fields
|
|
344
351
|
# for queryable encryption.
|
|
345
352
|
# @option opts [ Integer ] :expire_after Number indicating
|
|
@@ -399,7 +406,10 @@ module Mongo
|
|
|
399
406
|
self.write_concern
|
|
400
407
|
end
|
|
401
408
|
|
|
402
|
-
context = Operation::Context.new(
|
|
409
|
+
context = Operation::Context.new(
|
|
410
|
+
client: client,
|
|
411
|
+
session: session
|
|
412
|
+
)
|
|
403
413
|
maybe_create_qe_collections(opts[:encrypted_fields], client, session) do |encrypted_fields|
|
|
404
414
|
Operation::Create.new(
|
|
405
415
|
selector: operation,
|
|
@@ -411,7 +421,10 @@ module Mongo
|
|
|
411
421
|
collation: options[:collation] || options['collation'],
|
|
412
422
|
encrypted_fields: encrypted_fields,
|
|
413
423
|
validator: options[:validator],
|
|
414
|
-
).execute(
|
|
424
|
+
).execute(
|
|
425
|
+
next_primary(nil, session),
|
|
426
|
+
context: context
|
|
427
|
+
)
|
|
415
428
|
end
|
|
416
429
|
end
|
|
417
430
|
end
|
|
@@ -430,12 +443,16 @@ module Mongo
|
|
|
430
443
|
# @option opts [ Hash ] :write_concern The write concern options.
|
|
431
444
|
# @option opts [ Hash | nil ] :encrypted_fields Encrypted fields hash that
|
|
432
445
|
# was provided to `create` collection helper.
|
|
446
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
447
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
448
|
+
# The default value is unset which means the value is inherited from
|
|
449
|
+
# the collection or the database or the client.
|
|
433
450
|
#
|
|
434
451
|
# @return [ Result ] The result of the command.
|
|
435
452
|
#
|
|
436
453
|
# @since 2.0.0
|
|
437
454
|
def drop(opts = {})
|
|
438
|
-
client.
|
|
455
|
+
client.with_session(opts) do |session|
|
|
439
456
|
maybe_drop_emm_collections(opts[:encrypted_fields], client, session) do
|
|
440
457
|
temp_write_concern = write_concern
|
|
441
458
|
write_concern = if opts[:write_concern]
|
|
@@ -443,7 +460,11 @@ module Mongo
|
|
|
443
460
|
else
|
|
444
461
|
temp_write_concern
|
|
445
462
|
end
|
|
446
|
-
context = Operation::Context.new(
|
|
463
|
+
context = Operation::Context.new(
|
|
464
|
+
client: client,
|
|
465
|
+
session: session,
|
|
466
|
+
operation_timeouts: operation_timeouts(opts)
|
|
467
|
+
)
|
|
447
468
|
operation = Operation::Drop.new({
|
|
448
469
|
selector: { :drop => name },
|
|
449
470
|
db_name: database.name,
|
|
@@ -479,8 +500,9 @@ module Mongo
|
|
|
479
500
|
# this command.
|
|
480
501
|
# @option options [ :tailable, :tailable_await ] :cursor_type The type of cursor to use.
|
|
481
502
|
# @option options [ Integer ] :limit The max number of docs to return from the query.
|
|
482
|
-
# @option options [ Integer ] :max_time_ms
|
|
483
|
-
#
|
|
503
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
504
|
+
# allow the query to run, in milliseconds. This option is deprecated, use
|
|
505
|
+
# :timeout_ms instead.
|
|
484
506
|
# @option options [ Hash ] :modifiers A document containing meta-operators modifying the
|
|
485
507
|
# output or behavior of a query.
|
|
486
508
|
# @option options [ true | false ] :no_cursor_timeout The server normally times out idle
|
|
@@ -494,6 +516,13 @@ module Mongo
|
|
|
494
516
|
# @option options [ Integer ] :skip The number of docs to skip before returning results.
|
|
495
517
|
# @option options [ Hash ] :sort The key and direction pairs by which the result set
|
|
496
518
|
# will be sorted.
|
|
519
|
+
# @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
|
|
520
|
+
# :timeout_ms (whether it applies to the lifetime of the cursor, or per
|
|
521
|
+
# iteration).
|
|
522
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
523
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
524
|
+
# The default value is unset which means the value is inherited from
|
|
525
|
+
# the collection or the database or the client.
|
|
497
526
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
498
527
|
# See the server documentation for details.
|
|
499
528
|
#
|
|
@@ -524,13 +553,14 @@ module Mongo
|
|
|
524
553
|
# @option options [ String ] :hint The index to use for the aggregation.
|
|
525
554
|
# @option options [ Hash ] :let Mapping of variables to use in the pipeline.
|
|
526
555
|
# See the server documentation for details.
|
|
527
|
-
# @option options [ Integer ] :max_time_ms The maximum amount of time
|
|
528
|
-
#
|
|
529
|
-
#
|
|
530
|
-
# will request that the server provide results using a cursor. Note that
|
|
531
|
-
# as of server version 3.6, aggregations always provide results using a
|
|
532
|
-
# cursor and this option is therefore not valid.
|
|
556
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
557
|
+
# allow the query to run, in milliseconds. This option is deprecated, use
|
|
558
|
+
# :timeout_ms instead.
|
|
533
559
|
# @option options [ Session ] :session The session to use.
|
|
560
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
561
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
562
|
+
# The default value is unset which means the value is inherited from
|
|
563
|
+
# the collection or the database or the client.
|
|
534
564
|
#
|
|
535
565
|
# @return [ View::Aggregation ] The aggregation object.
|
|
536
566
|
#
|
|
@@ -598,6 +628,13 @@ module Mongo
|
|
|
598
628
|
# events included with this flag set are: createIndexes, dropIndexes,
|
|
599
629
|
# modify, create, shardCollection, reshardCollection,
|
|
600
630
|
# refineCollectionShardKey.
|
|
631
|
+
# @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
|
|
632
|
+
# :timeout_ms (whether it applies to the lifetime of the cursor, or per
|
|
633
|
+
# iteration).
|
|
634
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
635
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
636
|
+
# The default value is unset which means the value is inherited from
|
|
637
|
+
# the collection or the database or the client.
|
|
601
638
|
#
|
|
602
639
|
# @note A change stream only allows 'majority' read concern.
|
|
603
640
|
# @note This helper method is preferable to running a raw aggregation with
|
|
@@ -608,7 +645,7 @@ module Mongo
|
|
|
608
645
|
# @since 2.5.0
|
|
609
646
|
def watch(pipeline = [], options = {})
|
|
610
647
|
view_options = options.dup
|
|
611
|
-
view_options[:
|
|
648
|
+
view_options[:cursor_type] = :tailable_await if options[:max_await_time_ms]
|
|
612
649
|
View::ChangeStream.new(View.new(self, {}, view_options), pipeline, nil, options)
|
|
613
650
|
end
|
|
614
651
|
|
|
@@ -622,13 +659,19 @@ module Mongo
|
|
|
622
659
|
#
|
|
623
660
|
# @option options [ Hash ] :hint The index to use.
|
|
624
661
|
# @option options [ Integer ] :limit The maximum number of documents to count.
|
|
625
|
-
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
662
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
663
|
+
# allow the query to run, in milliseconds. This option is deprecated, use
|
|
664
|
+
# :timeout_ms instead.
|
|
626
665
|
# @option options [ Integer ] :skip The number of documents to skip before counting.
|
|
627
666
|
# @option options [ Hash ] :read The read preference options.
|
|
628
667
|
# @option options [ Hash ] :collation The collation to use.
|
|
629
668
|
# @option options [ Session ] :session The session to use.
|
|
630
669
|
# @option options [ Object ] :comment A user-provided
|
|
631
670
|
# comment to attach to this command.
|
|
671
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
672
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
673
|
+
# The default value is unset which means the value is inherited from
|
|
674
|
+
# the collection or the database or the client.
|
|
632
675
|
#
|
|
633
676
|
# @return [ Integer ] The document count.
|
|
634
677
|
#
|
|
@@ -665,6 +708,10 @@ module Mongo
|
|
|
665
708
|
# @option options [ Session ] :session The session to use.
|
|
666
709
|
# @option options [ Object ] :comment A user-provided
|
|
667
710
|
# comment to attach to this command.
|
|
711
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
712
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
713
|
+
# The default value is unset which means the value is inherited from
|
|
714
|
+
# the collection or the database or the client.
|
|
668
715
|
#
|
|
669
716
|
# @return [ Integer ] The document count.
|
|
670
717
|
#
|
|
@@ -686,6 +733,10 @@ module Mongo
|
|
|
686
733
|
# @option options [ Hash ] :read The read preference options.
|
|
687
734
|
# @option options [ Object ] :comment A user-provided
|
|
688
735
|
# comment to attach to this command.
|
|
736
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
737
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
738
|
+
# The default value is unset which means the value is inherited from
|
|
739
|
+
# the collection or the database or the client.
|
|
689
740
|
#
|
|
690
741
|
# @return [ Integer ] The document count.
|
|
691
742
|
#
|
|
@@ -703,10 +754,16 @@ module Mongo
|
|
|
703
754
|
# @param [ Hash ] filter The documents from which to retrieve the distinct values.
|
|
704
755
|
# @param [ Hash ] options The distinct command options.
|
|
705
756
|
#
|
|
706
|
-
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
757
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
758
|
+
# allow the query to run, in milliseconds. This option is deprecated, use
|
|
759
|
+
# :timeout_ms instead.
|
|
707
760
|
# @option options [ Hash ] :read The read preference options.
|
|
708
761
|
# @option options [ Hash ] :collation The collation to use.
|
|
709
762
|
# @option options [ Session ] :session The session to use.
|
|
763
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
764
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
765
|
+
# The default value is unset which means the value is inherited from
|
|
766
|
+
# the collection or the database or the client.
|
|
710
767
|
#
|
|
711
768
|
# @return [ Array<Object> ] The list of distinct values.
|
|
712
769
|
#
|
|
@@ -725,13 +782,35 @@ module Mongo
|
|
|
725
782
|
#
|
|
726
783
|
# @option options [ Session ] :session The session to use.
|
|
727
784
|
#
|
|
728
|
-
# @return [ View
|
|
785
|
+
# @return [ Index::View ] The index view.
|
|
729
786
|
#
|
|
730
787
|
# @since 2.0.0
|
|
731
788
|
def indexes(options = {})
|
|
732
789
|
Index::View.new(self, options)
|
|
733
790
|
end
|
|
734
791
|
|
|
792
|
+
# Get a view of all search indexes for this collection. Can be iterated or
|
|
793
|
+
# operated on directly. If id or name are given, the iterator will return
|
|
794
|
+
# only the indicated index. For all other operations, id and name are
|
|
795
|
+
# ignored.
|
|
796
|
+
#
|
|
797
|
+
# @note Only one of id or name may be given; it is an error to specify both,
|
|
798
|
+
# although both may be omitted safely.
|
|
799
|
+
#
|
|
800
|
+
# @param [ Hash ] options The options to use to configure the view.
|
|
801
|
+
#
|
|
802
|
+
# @option options [ String ] :id The id of the specific index to query (optional)
|
|
803
|
+
# @option options [ String ] :name The name of the specific index to query (optional)
|
|
804
|
+
# @option options [ Hash ] :aggregate The options hash to pass to the
|
|
805
|
+
# aggregate command (optional)
|
|
806
|
+
#
|
|
807
|
+
# @return [ SearchIndex::View ] The search index view.
|
|
808
|
+
#
|
|
809
|
+
# @since 2.0.0
|
|
810
|
+
def search_indexes(options = {})
|
|
811
|
+
SearchIndex::View.new(self, options)
|
|
812
|
+
end
|
|
813
|
+
|
|
735
814
|
# Get a pretty printed string inspection for the collection.
|
|
736
815
|
#
|
|
737
816
|
# @example Inspect the collection.
|
|
@@ -757,6 +836,10 @@ module Mongo
|
|
|
757
836
|
# @option opts [ Object ] :comment A user-provided comment to attach to
|
|
758
837
|
# this command.
|
|
759
838
|
# @option opts [ Session ] :session The session to use for the operation.
|
|
839
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
840
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
841
|
+
# The default value is unset which means the value is inherited from
|
|
842
|
+
# the collection or the database or the client.
|
|
760
843
|
# @option opts [ Hash ] :write_concern The write concern options.
|
|
761
844
|
# Can be :w => Integer, :fsync => Boolean, :j => Boolean.
|
|
762
845
|
#
|
|
@@ -766,7 +849,7 @@ module Mongo
|
|
|
766
849
|
def insert_one(document, opts = {})
|
|
767
850
|
QueryCache.clear_namespace(namespace)
|
|
768
851
|
|
|
769
|
-
client.
|
|
852
|
+
client.with_session(opts) do |session|
|
|
770
853
|
write_concern = if opts[:write_concern]
|
|
771
854
|
WriteConcern.get(opts[:write_concern])
|
|
772
855
|
else
|
|
@@ -777,7 +860,11 @@ module Mongo
|
|
|
777
860
|
raise ArgumentError, "Document to be inserted cannot be nil"
|
|
778
861
|
end
|
|
779
862
|
|
|
780
|
-
context = Operation::Context.new(
|
|
863
|
+
context = Operation::Context.new(
|
|
864
|
+
client: client,
|
|
865
|
+
session: session,
|
|
866
|
+
operation_timeouts: operation_timeouts(opts)
|
|
867
|
+
)
|
|
781
868
|
write_with_retry(write_concern, context: context) do |connection, txn_num, context|
|
|
782
869
|
Operation::Insert.new(
|
|
783
870
|
:documents => [ document ],
|
|
@@ -810,6 +897,10 @@ module Mongo
|
|
|
810
897
|
# @option options [ true | false ] :ordered Whether the operations
|
|
811
898
|
# should be executed in order.
|
|
812
899
|
# @option options [ Session ] :session The session to use for the operation.
|
|
900
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
901
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
902
|
+
# The default value is unset which means the value is inherited from
|
|
903
|
+
# the collection or the database or the client.
|
|
813
904
|
# @option options [ Hash ] :write_concern The write concern options.
|
|
814
905
|
# Can be :w => Integer, :fsync => Boolean, :j => Boolean.
|
|
815
906
|
#
|
|
@@ -838,6 +929,10 @@ module Mongo
|
|
|
838
929
|
# @option options [ true | false ] :bypass_document_validation Whether or
|
|
839
930
|
# not to skip document level validation.
|
|
840
931
|
# @option options [ Session ] :session The session to use for the set of operations.
|
|
932
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
933
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
934
|
+
# The default value is unset which means the value is inherited from
|
|
935
|
+
# the collection or the database or the client.
|
|
841
936
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
842
937
|
# See the server documentation for details.
|
|
843
938
|
#
|
|
@@ -860,6 +955,10 @@ module Mongo
|
|
|
860
955
|
# @option options [ Session ] :session The session to use.
|
|
861
956
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
862
957
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
958
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
959
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
960
|
+
# The default value is unset which means the value is inherited from
|
|
961
|
+
# the collection or the database or the client.
|
|
863
962
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
864
963
|
# See the server documentation for details.
|
|
865
964
|
#
|
|
@@ -882,6 +981,10 @@ module Mongo
|
|
|
882
981
|
# @option options [ Session ] :session The session to use.
|
|
883
982
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
884
983
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
984
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
985
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
986
|
+
# The default value is unset which means the value is inherited from
|
|
987
|
+
# the collection or the database or the client.
|
|
885
988
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
886
989
|
# See the server documentation for details.
|
|
887
990
|
#
|
|
@@ -904,15 +1007,23 @@ module Mongo
|
|
|
904
1007
|
# @param [ Integer ] cursor_count The max number of cursors to return.
|
|
905
1008
|
# @param [ Hash ] options The parallel scan command options.
|
|
906
1009
|
#
|
|
907
|
-
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
908
|
-
# to run in milliseconds.
|
|
1010
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
1011
|
+
# allow the query to run, in milliseconds. This option is deprecated, use
|
|
1012
|
+
# :timeout_ms instead.
|
|
909
1013
|
# @option options [ Session ] :session The session to use.
|
|
1014
|
+
# @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
|
|
1015
|
+
# :timeout_ms (whether it applies to the lifetime of the cursor, or per
|
|
1016
|
+
# iteration).
|
|
1017
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1018
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1019
|
+
# The default value is unset which means the value is inherited from
|
|
1020
|
+
# the collection or the database or the client.
|
|
910
1021
|
#
|
|
911
1022
|
# @return [ Array<Cursor> ] An array of cursors.
|
|
912
1023
|
#
|
|
913
1024
|
# @since 2.1
|
|
914
1025
|
def parallel_scan(cursor_count, options = {})
|
|
915
|
-
find({}, options).
|
|
1026
|
+
find({}, options).parallel_scan(cursor_count, options)
|
|
916
1027
|
end
|
|
917
1028
|
|
|
918
1029
|
# Replaces a single document in the collection with the new document.
|
|
@@ -930,6 +1041,10 @@ module Mongo
|
|
|
930
1041
|
# not to skip document level validation.
|
|
931
1042
|
# @option options [ Hash ] :collation The collation to use.
|
|
932
1043
|
# @option options [ Session ] :session The session to use.
|
|
1044
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1045
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1046
|
+
# The default value is unset which means the value is inherited from
|
|
1047
|
+
# the collection or the database or the client.
|
|
933
1048
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
934
1049
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
935
1050
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
@@ -959,6 +1074,10 @@ module Mongo
|
|
|
959
1074
|
# @option options [ Array ] :array_filters A set of filters specifying to which array elements
|
|
960
1075
|
# an update should apply.
|
|
961
1076
|
# @option options [ Session ] :session The session to use.
|
|
1077
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1078
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1079
|
+
# The default value is unset which means the value is inherited from
|
|
1080
|
+
# the collection or the database or the client.
|
|
962
1081
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
963
1082
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
964
1083
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
@@ -988,6 +1107,10 @@ module Mongo
|
|
|
988
1107
|
# @option options [ Array ] :array_filters A set of filters specifying to which array elements
|
|
989
1108
|
# an update should apply.
|
|
990
1109
|
# @option options [ Session ] :session The session to use.
|
|
1110
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1111
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1112
|
+
# The default value is unset which means the value is inherited from
|
|
1113
|
+
# the collection or the database or the client.
|
|
991
1114
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
992
1115
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
993
1116
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
@@ -1009,8 +1132,9 @@ module Mongo
|
|
|
1009
1132
|
# @param [ Hash ] filter The filter to use.
|
|
1010
1133
|
# @param [ Hash ] options The options.
|
|
1011
1134
|
#
|
|
1012
|
-
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
1013
|
-
# to run in milliseconds.
|
|
1135
|
+
# @option options [ Integer ] :max_time_ms The maximum amount of time to
|
|
1136
|
+
# allow the query to run, in milliseconds. This option is deprecated, use
|
|
1137
|
+
# :timeout_ms instead.
|
|
1014
1138
|
# @option options [ Hash ] :projection The fields to include or exclude in the returned doc.
|
|
1015
1139
|
# @option options [ Hash ] :sort The key and direction pairs by which the result set
|
|
1016
1140
|
# will be sorted.
|
|
@@ -1018,6 +1142,10 @@ module Mongo
|
|
|
1018
1142
|
# Defaults to the collection's write concern.
|
|
1019
1143
|
# @option options [ Hash ] :collation The collation to use.
|
|
1020
1144
|
# @option options [ Session ] :session The session to use.
|
|
1145
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1146
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1147
|
+
# The default value is unset which means the value is inherited from
|
|
1148
|
+
# the collection or the database or the client.
|
|
1021
1149
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
1022
1150
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
1023
1151
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
@@ -1062,6 +1190,10 @@ module Mongo
|
|
|
1062
1190
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
1063
1191
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
1064
1192
|
# See the server documentation for details.
|
|
1193
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1194
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1195
|
+
# The default value is unset which means the value is inherited from
|
|
1196
|
+
# the collection or the database or the client.
|
|
1065
1197
|
#
|
|
1066
1198
|
# @return [ BSON::Document ] The document.
|
|
1067
1199
|
#
|
|
@@ -1098,6 +1230,10 @@ module Mongo
|
|
|
1098
1230
|
# @option options [ Session ] :session The session to use.
|
|
1099
1231
|
# @option options [ Hash | String ] :hint The index to use for this operation.
|
|
1100
1232
|
# May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
|
|
1233
|
+
# @option options [ Integer ] :timeout_ms The operation timeout in milliseconds.
|
|
1234
|
+
# Must be a non-negative integer. An explicit value of 0 means infinite.
|
|
1235
|
+
# The default value is unset which means the value is inherited from
|
|
1236
|
+
# the collection or the database or the client.
|
|
1101
1237
|
# @option options [ Hash ] :let Mapping of variables to use in the command.
|
|
1102
1238
|
# See the server documentation for details.
|
|
1103
1239
|
#
|
|
@@ -1128,5 +1264,28 @@ module Mongo
|
|
|
1128
1264
|
def system_collection?
|
|
1129
1265
|
name.start_with?('system.')
|
|
1130
1266
|
end
|
|
1267
|
+
|
|
1268
|
+
# @return [ Integer | nil ] Operation timeout that is for this database or
|
|
1269
|
+
# for the corresponding client.
|
|
1270
|
+
#
|
|
1271
|
+
# @api private
|
|
1272
|
+
def timeout_ms
|
|
1273
|
+
@timeout_ms || database.timeout_ms
|
|
1274
|
+
end
|
|
1275
|
+
|
|
1276
|
+
# @return [ Hash ] timeout_ms value set on the operation level (if any),
|
|
1277
|
+
# and/or timeout_ms that is set on collection/database/client level (if any).
|
|
1278
|
+
#
|
|
1279
|
+
# @api private
|
|
1280
|
+
def operation_timeouts(opts = {})
|
|
1281
|
+
# TODO: We should re-evaluate if we need two timeouts separately.
|
|
1282
|
+
{}.tap do |result|
|
|
1283
|
+
if opts[:timeout_ms].nil?
|
|
1284
|
+
result[:inherited_timeout_ms] = timeout_ms
|
|
1285
|
+
else
|
|
1286
|
+
result[:operation_timeout_ms] = opts.delete(:timeout_ms)
|
|
1287
|
+
end
|
|
1288
|
+
end
|
|
1289
|
+
end
|
|
1131
1290
|
end
|
|
1132
1291
|
end
|
data/lib/mongo/config.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Mongo
|
|
|
16
16
|
|
|
17
17
|
# When this flag is off, an aggregation done on a view will be executed over
|
|
18
18
|
# the documents included in that view, instead of all documents in the
|
|
19
|
-
# collection. When this flag is on, the view
|
|
19
|
+
# collection. When this flag is on, the view filter is ignored.
|
|
20
20
|
option :broken_view_aggregate, default: true
|
|
21
21
|
|
|
22
22
|
# When this flag is set to false, the view options will be correctly
|
|
@@ -24,7 +24,7 @@ module Mongo
|
|
|
24
24
|
option :broken_view_options, default: true
|
|
25
25
|
|
|
26
26
|
# When this flag is set to true, the update and replace methods will
|
|
27
|
-
# validate the
|
|
27
|
+
# validate the parameters and raise an error if they are invalid.
|
|
28
28
|
option :validate_update_replace, default: false
|
|
29
29
|
|
|
30
30
|
# Set the configuration options.
|
|
@@ -119,8 +119,6 @@ module Mongo
|
|
|
119
119
|
@options[:extra_options][:crypt_shared_lib_required]
|
|
120
120
|
|
|
121
121
|
unless @options[:extra_options][:crypt_shared_lib_required] || @crypt_handle.crypt_shared_lib_available? || @options[:bypass_query_analysis]
|
|
122
|
-
# Set server selection timeout to 1 to prevent the client waiting for a
|
|
123
|
-
# long timeout before spawning mongocryptd
|
|
124
122
|
@mongocryptd_client = Client.new(
|
|
125
123
|
@options[:extra_options][:mongocryptd_uri],
|
|
126
124
|
monitoring_io: @options[:client].options[:monitoring_io],
|
|
@@ -189,13 +187,13 @@ module Mongo
|
|
|
189
187
|
# @param [ Hash ] command The command to be encrypted.
|
|
190
188
|
#
|
|
191
189
|
# @return [ BSON::Document ] The encrypted command.
|
|
192
|
-
def encrypt(database_name, command)
|
|
190
|
+
def encrypt(database_name, command, timeout_holder)
|
|
193
191
|
AutoEncryptionContext.new(
|
|
194
192
|
@crypt_handle,
|
|
195
193
|
@encryption_io,
|
|
196
194
|
database_name,
|
|
197
195
|
command
|
|
198
|
-
).run_state_machine
|
|
196
|
+
).run_state_machine(timeout_holder)
|
|
199
197
|
end
|
|
200
198
|
|
|
201
199
|
# Decrypt a database command.
|
|
@@ -203,12 +201,12 @@ module Mongo
|
|
|
203
201
|
# @param [ Hash ] command The command with encrypted fields.
|
|
204
202
|
#
|
|
205
203
|
# @return [ BSON::Document ] The decrypted command.
|
|
206
|
-
def decrypt(command)
|
|
204
|
+
def decrypt(command, timeout_holder)
|
|
207
205
|
AutoDecryptionContext.new(
|
|
208
206
|
@crypt_handle,
|
|
209
207
|
@encryption_io,
|
|
210
208
|
command
|
|
211
|
-
).run_state_machine
|
|
209
|
+
).run_state_machine(timeout_holder)
|
|
212
210
|
end
|
|
213
211
|
|
|
214
212
|
# Close the resources created by the AutoEncrypter.
|
data/lib/mongo/crypt/binding.rb
CHANGED
|
@@ -1699,9 +1699,9 @@ module Mongo
|
|
|
1699
1699
|
# @!method self.mongocrypt_ctx_setopt_algorithm_range(ctx, opts)
|
|
1700
1700
|
# @api private
|
|
1701
1701
|
#
|
|
1702
|
-
# Set options for explicit encryption with the "
|
|
1702
|
+
# Set options for explicit encryption with the "range" algorithm.
|
|
1703
1703
|
#
|
|
1704
|
-
# @note The
|
|
1704
|
+
# @note The Range algorithm is experimental only. It is not intended for
|
|
1705
1705
|
# public use.
|
|
1706
1706
|
#
|
|
1707
1707
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
@@ -1718,9 +1718,9 @@ module Mongo
|
|
|
1718
1718
|
:bool
|
|
1719
1719
|
)
|
|
1720
1720
|
|
|
1721
|
-
# Set options for explicit encryption with the "
|
|
1721
|
+
# Set options for explicit encryption with the "range" algorithm.
|
|
1722
1722
|
#
|
|
1723
|
-
# @note The
|
|
1723
|
+
# @note The Range algorithm is experimental only. It is not intended for
|
|
1724
1724
|
# public use.
|
|
1725
1725
|
#
|
|
1726
1726
|
# @param [ Mongo::Crypt::Context ] context
|