mongo 2.15.0 → 2.16.1
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
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/mongo/bulk_write.rb +2 -2
- data/lib/mongo/client.rb +45 -5
- data/lib/mongo/cluster/periodic_executor.rb +4 -3
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +76 -43
- data/lib/mongo/cluster/sdam_flow.rb +9 -3
- data/lib/mongo/cluster/topology/base.rb +13 -9
- data/lib/mongo/cluster/topology/load_balanced.rb +102 -0
- data/lib/mongo/cluster/topology.rb +28 -8
- data/lib/mongo/cluster.rb +136 -51
- data/lib/mongo/collection/view/aggregation.rb +5 -10
- data/lib/mongo/collection/view/builder/aggregation.rb +6 -5
- data/lib/mongo/collection/view/builder/map_reduce.rb +12 -49
- data/lib/mongo/collection/view/builder.rb +0 -4
- data/lib/mongo/collection/view/iterable.rb +58 -24
- data/lib/mongo/collection/view/map_reduce.rb +39 -15
- data/lib/mongo/collection/view/readable.rb +60 -51
- data/lib/mongo/collection/view/writable.rb +178 -175
- data/lib/mongo/collection/view.rb +15 -21
- data/lib/mongo/collection.rb +13 -13
- data/lib/mongo/cursor/kill_spec.rb +38 -0
- data/lib/mongo/cursor.rb +72 -31
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/error/bad_load_balancer_target.rb +26 -0
- data/lib/mongo/error/missing_service_id.rb +26 -0
- data/lib/mongo/error/no_service_connection_available.rb +49 -0
- data/lib/mongo/error/notable.rb +7 -0
- data/lib/mongo/error.rb +3 -0
- data/lib/mongo/grid/fs_bucket.rb +21 -2
- data/lib/mongo/id.rb +7 -5
- data/lib/mongo/index/view.rb +22 -41
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +7 -4
- data/lib/mongo/monitoring/event/command_failed.rb +1 -1
- data/lib/mongo/monitoring/event/command_started.rb +2 -0
- data/lib/mongo/monitoring/publishable.rb +2 -2
- data/lib/mongo/operation/aggregate/command.rb +8 -0
- data/lib/mongo/operation/context.rb +19 -1
- data/lib/mongo/operation/count/command.rb +6 -0
- data/lib/mongo/operation/count/op_msg.rb +6 -0
- data/lib/mongo/operation/create/command.rb +7 -1
- data/lib/mongo/operation/create/op_msg.rb +7 -0
- data/lib/mongo/operation/create_index/command.rb +17 -1
- data/lib/mongo/operation/create_index/op_msg.rb +17 -4
- data/lib/mongo/operation/delete/command.rb +6 -3
- data/lib/mongo/operation/delete/legacy.rb +9 -2
- data/lib/mongo/operation/delete/op_msg.rb +8 -1
- data/lib/mongo/operation/distinct/command.rb +6 -0
- data/lib/mongo/operation/distinct/op_msg.rb +7 -0
- data/lib/mongo/operation/explain/command.rb +13 -1
- data/lib/mongo/operation/explain/legacy.rb +12 -5
- data/lib/mongo/operation/explain/op_msg.rb +9 -1
- data/lib/mongo/operation/find/builder/command.rb +110 -0
- data/lib/mongo/{collection/view → operation/find}/builder/flags.rb +10 -14
- data/lib/mongo/operation/find/builder/legacy.rb +123 -0
- data/lib/mongo/{collection/view → operation/find}/builder/modifiers.rb +31 -25
- data/lib/mongo/{cursor → operation/find}/builder.rb +4 -4
- data/lib/mongo/operation/find/command.rb +9 -0
- data/lib/mongo/operation/find/legacy.rb +10 -1
- data/lib/mongo/operation/find/op_msg.rb +12 -0
- data/lib/mongo/operation/find.rb +1 -0
- data/lib/mongo/operation/get_more/command.rb +1 -0
- data/lib/mongo/operation/get_more/command_builder.rb +38 -0
- data/lib/mongo/operation/get_more/op_msg.rb +1 -0
- data/lib/mongo/operation/get_more.rb +1 -0
- data/lib/mongo/operation/kill_cursors/command.rb +8 -0
- data/lib/mongo/operation/kill_cursors/command_builder.rb +35 -0
- data/lib/mongo/operation/kill_cursors/legacy.rb +2 -1
- data/lib/mongo/operation/kill_cursors/op_msg.rb +10 -0
- data/lib/mongo/operation/kill_cursors.rb +1 -0
- data/lib/mongo/operation/map_reduce/command.rb +8 -0
- data/lib/mongo/operation/map_reduce/op_msg.rb +1 -1
- data/lib/mongo/operation/shared/executable.rb +15 -1
- data/lib/mongo/operation/shared/polymorphic_operation.rb +1 -1
- data/lib/mongo/operation/shared/read_preference_supported.rb +3 -1
- data/lib/mongo/operation/shared/response_handling.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +12 -12
- data/lib/mongo/operation/shared/specifiable.rb +11 -29
- data/lib/mongo/operation/shared/validatable.rb +87 -0
- data/lib/mongo/operation/shared/write.rb +1 -1
- data/lib/mongo/operation/update/command.rb +6 -3
- data/lib/mongo/operation/update/legacy.rb +19 -11
- data/lib/mongo/operation/update/op_msg.rb +7 -4
- data/lib/mongo/operation/write_command/command.rb +51 -0
- data/lib/mongo/operation/write_command/op_msg.rb +43 -0
- data/lib/mongo/operation/write_command.rb +32 -0
- data/lib/mongo/operation.rb +10 -0
- data/lib/mongo/protocol/query.rb +35 -18
- data/lib/mongo/server/connection.rb +25 -3
- data/lib/mongo/server/connection_base.rb +12 -1
- data/lib/mongo/server/connection_common.rb +38 -1
- data/lib/mongo/server/connection_pool/generation_manager.rb +71 -0
- data/lib/mongo/server/connection_pool.rb +100 -27
- data/lib/mongo/server/description/features.rb +17 -16
- data/lib/mongo/server/description/load_balancer.rb +33 -0
- data/lib/mongo/server/description.rb +85 -6
- data/lib/mongo/server/monitor/connection.rb +5 -6
- data/lib/mongo/server/monitor.rb +2 -1
- data/lib/mongo/server/pending_connection.rb +47 -31
- data/lib/mongo/server/push_monitor.rb +10 -1
- data/lib/mongo/server.rb +73 -26
- data/lib/mongo/server_selector/base.rb +5 -1
- data/lib/mongo/session/session_pool.rb +11 -0
- data/lib/mongo/session.rb +21 -1
- data/lib/mongo/socket/ocsp_verifier.rb +6 -37
- data/lib/mongo/uri/options_mapper.rb +1 -0
- data/lib/mongo/uri/srv_protocol.rb +6 -8
- data/lib/mongo/uri.rb +18 -0
- data/lib/mongo/utils.rb +0 -7
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/integration/auth_spec.rb +31 -1
- data/spec/integration/awaited_ismaster_spec.rb +1 -1
- data/spec/integration/bulk_write_spec.rb +1 -1
- data/spec/integration/change_stream_spec.rb +3 -3
- data/spec/integration/client_construction_spec.rb +54 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +1 -1
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +1 -1
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +1 -1
- data/spec/integration/client_side_encryption/data_key_spec.rb +1 -1
- data/spec/integration/client_spec.rb +2 -0
- data/spec/integration/command_monitoring_spec.rb +1 -1
- data/spec/integration/command_spec.rb +1 -1
- data/spec/integration/connection_spec.rb +52 -35
- data/spec/integration/crud_spec.rb +174 -1
- data/spec/integration/cursor_pinning_spec.rb +121 -0
- data/spec/integration/cursor_reaping_spec.rb +8 -4
- data/spec/integration/fork_reconnect_spec.rb +1 -5
- data/spec/integration/get_more_spec.rb +1 -1
- data/spec/integration/heartbeat_events_spec.rb +1 -1
- data/spec/integration/map_reduce_spec.rb +77 -0
- data/spec/integration/query_cache_spec.rb +47 -2
- data/spec/integration/query_cache_transactions_spec.rb +1 -1
- data/spec/integration/read_concern_spec.rb +1 -1
- data/spec/integration/read_preference_spec.rb +1 -1
- data/spec/integration/reconnect_spec.rb +30 -12
- data/spec/integration/retryable_errors_spec.rb +1 -1
- data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +1 -1
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -1
- data/spec/integration/sdam_error_handling_spec.rb +5 -3
- data/spec/integration/sdam_events_spec.rb +35 -19
- data/spec/integration/sdam_prose_spec.rb +1 -1
- data/spec/integration/server_monitor_spec.rb +1 -0
- data/spec/integration/server_selector_spec.rb +22 -5
- data/spec/integration/server_spec.rb +2 -0
- data/spec/integration/srv_monitoring_spec.rb +1 -1
- data/spec/integration/step_down_spec.rb +1 -1
- data/spec/integration/transaction_pinning_spec.rb +120 -0
- data/spec/integration/versioned_api_examples_spec.rb +45 -0
- data/spec/integration/x509_auth_spec.rb +1 -1
- data/spec/lite_spec_helper.rb +1 -2
- data/spec/mongo/address/unix_spec.rb +1 -0
- data/spec/mongo/auth/cr_spec.rb +2 -3
- data/spec/mongo/auth/ldap_spec.rb +2 -3
- data/spec/mongo/auth/scram_spec.rb +2 -3
- data/spec/mongo/auth/user/view_spec.rb +1 -1
- data/spec/mongo/auth/x509_spec.rb +2 -3
- data/spec/mongo/bulk_write_spec.rb +3 -3
- data/spec/mongo/client_construction_spec.rb +259 -28
- data/spec/mongo/client_spec.rb +6 -4
- data/spec/mongo/cluster/cursor_reaper_spec.rb +36 -21
- data/spec/mongo/cluster/periodic_executor_spec.rb +3 -1
- data/spec/mongo/cluster_spec.rb +44 -3
- data/spec/mongo/collection/view/aggregation_spec.rb +1 -1
- data/spec/mongo/collection/view/builder/find_command_spec.rb +4 -0
- data/spec/mongo/collection/view/builder/op_query_spec.rb +4 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +1 -1
- data/spec/mongo/collection_crud_spec.rb +7 -2
- data/spec/mongo/collection_ddl_spec.rb +1 -1
- data/spec/mongo/collection_spec.rb +1 -1
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +4 -0
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +4 -0
- data/spec/mongo/cursor_spec.rb +15 -5
- data/spec/mongo/database_spec.rb +15 -15
- data/spec/mongo/error/operation_failure_heavy_spec.rb +1 -1
- data/spec/mongo/grid/fs_bucket_spec.rb +18 -12
- data/spec/mongo/grid/stream/write_spec.rb +3 -9
- data/spec/mongo/grid/stream_spec.rb +1 -1
- data/spec/mongo/index/view_spec.rb +2 -2
- data/spec/mongo/operation/delete/op_msg_spec.rb +1 -1
- data/spec/mongo/{collection/view → operation/find}/builder/flags_spec.rb +2 -2
- data/spec/mongo/{collection/view → operation/find}/builder/modifiers_spec.rb +2 -2
- data/spec/mongo/operation/find/legacy_spec.rb +1 -0
- data/spec/mongo/operation/insert/bulk_spec.rb +1 -1
- data/spec/mongo/operation/insert/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/kill_cursors_spec.rb +4 -1
- data/spec/mongo/operation/read_preference_legacy_spec.rb +4 -0
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +2 -0
- data/spec/mongo/operation/update/bulk_spec.rb +1 -1
- data/spec/mongo/operation/update/op_msg_spec.rb +1 -1
- data/spec/mongo/query_cache_spec.rb +6 -2
- data/spec/mongo/server/connection_common_spec.rb +62 -11
- data/spec/mongo/server/connection_pool_spec.rb +73 -7
- data/spec/mongo/server/connection_spec.rb +138 -43
- data/spec/mongo/server/description_spec.rb +1 -1
- data/spec/mongo/server/monitor/connection_spec.rb +22 -0
- data/spec/mongo/server/monitor_spec.rb +4 -3
- data/spec/mongo/server/push_monitor_spec.rb +101 -0
- data/spec/mongo/session/session_pool_spec.rb +42 -10
- data/spec/mongo/session_transaction_spec.rb +15 -30
- data/spec/mongo/socket/unix_spec.rb +1 -0
- data/spec/mongo/uri_option_parsing_spec.rb +38 -5
- data/spec/runners/change_streams/test.rb +1 -1
- data/spec/runners/cmap.rb +1 -1
- data/spec/runners/connection_string.rb +7 -3
- data/spec/runners/crud/operation.rb +5 -3
- data/spec/runners/crud/requirement.rb +1 -0
- data/spec/runners/crud.rb +1 -1
- data/spec/runners/sdam.rb +2 -1
- data/spec/runners/transactions/test.rb +2 -2
- data/spec/runners/unified/assertions.rb +2 -3
- data/spec/runners/unified/event_subscriber.rb +2 -2
- data/spec/runners/unified/support_operations.rb +10 -2
- data/spec/runners/unified/test.rb +3 -0
- data/spec/runners/unified.rb +1 -1
- data/spec/shared/lib/mrss/cluster_config.rb +6 -1
- data/spec/shared/lib/mrss/constraints.rb +11 -5
- data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +17 -12
- data/spec/shared/share/Dockerfile.erb +5 -4
- data/spec/shared/shlib/server.sh +70 -20
- data/spec/spec_tests/change_streams_spec.rb +1 -1
- data/spec/spec_tests/cmap_spec.rb +4 -1
- data/spec/spec_tests/command_monitoring_spec.rb +2 -2
- data/spec/spec_tests/data/command_monitoring/find.yml +9 -9
- data/spec/spec_tests/data/crud/read/aggregate-collation.yml +2 -1
- data/spec/spec_tests/data/crud/read/aggregate-out.yml +1 -0
- data/spec/spec_tests/data/crud/read/count-collation.yml +2 -1
- data/spec/spec_tests/data/crud/read/distinct-collation.yml +2 -1
- data/spec/spec_tests/data/crud/read/find-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/deleteMany-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/deleteOne-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/findOneAndDelete-collation.yml +3 -2
- data/spec/spec_tests/data/crud/write/findOneAndReplace-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/findOneAndUpdate-collation.yml +3 -2
- data/spec/spec_tests/data/crud/write/replaceOne-collation.yml +3 -2
- data/spec/spec_tests/data/crud/write/updateMany-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/updateOne-collation.yml +2 -1
- data/spec/spec_tests/data/load_balancers/event-monitoring.yml +99 -0
- data/spec/spec_tests/data/load_balancers/lb-connection-establishment.yml +36 -0
- data/spec/spec_tests/data/load_balancers/non-lb-connection-establishment.yml +56 -0
- data/spec/spec_tests/data/load_balancers/server-selection.yml +50 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +3 -1
- data/spec/spec_tests/data/sdam/load-balanced/discover_load_balancer.yml +25 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +3 -1
- data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +3 -1
- data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +2 -0
- data/spec/spec_tests/data/sdam_monitoring/load_balancer.yml +65 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-directConnection.yml +13 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-replicaSet-errors.yml +6 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-multiple-hosts.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-txt.yml +10 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/direct-connection-false.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/direct-connection-true.yml +0 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/encoded-userinfo-and-db.yml +15 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/loadBalanced-false-txt.yml +10 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/longer-parent-in-return.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/misformatted-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/no-results.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/not-enough-parts.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-result-default-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-txt-record-multiple-strings.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-txt-record.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch1.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch2.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch3.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch4.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch5.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/returned-parent-too-short.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/returned-parent-wrong.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-results-default-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-results-nonstandard-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-txt-records.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-not-allowed-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-overridden-ssl-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-overridden-uri-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-unallowed-option.yml +0 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-admin-database.yml +13 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-auth.yml +12 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/uri-with-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/uri-with-two-hosts.yml +0 -0
- data/spec/spec_tests/data/transactions/retryable-abort-errorLabels.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-abort.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-commit-errorLabels.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-commit.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-writes.yml +2 -0
- data/spec/spec_tests/data/uri_options/connection-options.yml +60 -0
- data/spec/spec_tests/load_balancers_spec.rb +15 -0
- data/spec/spec_tests/retryable_reads_spec.rb +2 -2
- data/spec/spec_tests/retryable_writes_spec.rb +1 -1
- data/spec/spec_tests/sdam_integration_spec.rb +1 -1
- data/spec/spec_tests/sdam_monitoring_spec.rb +10 -5
- data/spec/spec_tests/sdam_spec.rb +1 -1
- data/spec/spec_tests/seed_list_discovery_spec.rb +118 -0
- data/spec/spec_tests/uri_options_spec.rb +4 -4
- data/spec/stress/fork_reconnect_stress_spec.rb +1 -5
- data/spec/stress/push_monitor_close_spec.rb +44 -0
- data/spec/support/certificates/atlas-ocsp-ca.crt +82 -90
- data/spec/support/certificates/atlas-ocsp.crt +127 -122
- data/spec/support/common_shortcuts.rb +2 -3
- data/spec/support/matchers.rb +13 -0
- data/spec/support/shared/auth_context.rb +16 -0
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +10 -11
- data/spec/support/using_hash.rb +31 -0
- data/spec/support/utils.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1077 -1029
- metadata.gz.sig +0 -0
- data/lib/mongo/collection/view/builder/find_command.rb +0 -173
- data/lib/mongo/collection/view/builder/op_query.rb +0 -94
- data/lib/mongo/cursor/builder/get_more_command.rb +0 -80
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +0 -111
- data/lib/mongo/cursor/builder/op_get_more.rb +0 -64
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +0 -106
- data/lib/mongo/server/context.rb +0 -72
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +0 -66
- data/spec/runners/unified/using_hash.rb +0 -34
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +0 -79
- data/spec/support/event_subscriber.rb +0 -221
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,173 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2015-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Collection
|
20
|
-
class View
|
21
|
-
module Builder
|
22
|
-
|
23
|
-
# Builds a find command specification from options.
|
24
|
-
#
|
25
|
-
# @since 2.2.0
|
26
|
-
class FindCommand
|
27
|
-
extend Forwardable
|
28
|
-
|
29
|
-
# The mappings from ruby options to the find command.
|
30
|
-
#
|
31
|
-
# @since 2.2.0
|
32
|
-
MAPPINGS = BSON::Document.new(
|
33
|
-
sort: 'sort',
|
34
|
-
projection: 'projection',
|
35
|
-
hint: 'hint',
|
36
|
-
skip: 'skip',
|
37
|
-
limit: 'limit',
|
38
|
-
batch_size: 'batchSize',
|
39
|
-
single_batch: 'singleBatch',
|
40
|
-
comment: 'comment',
|
41
|
-
max_scan: 'maxScan',
|
42
|
-
max_time_ms: 'maxTimeMS',
|
43
|
-
max_value: 'max',
|
44
|
-
min_value: 'min',
|
45
|
-
return_key: 'returnKey',
|
46
|
-
show_disk_loc: 'showRecordId',
|
47
|
-
snapshot: 'snapshot',
|
48
|
-
tailable: 'tailable',
|
49
|
-
tailable_cursor: 'tailable',
|
50
|
-
oplog_replay: 'oplogReplay',
|
51
|
-
no_cursor_timeout: 'noCursorTimeout',
|
52
|
-
await_data: 'awaitData',
|
53
|
-
allow_partial_results: 'allowPartialResults',
|
54
|
-
allow_disk_use: 'allowDiskUse',
|
55
|
-
collation: 'collation'
|
56
|
-
).freeze
|
57
|
-
|
58
|
-
# Create the find command builder.
|
59
|
-
#
|
60
|
-
# @example Create the find command builder.
|
61
|
-
# FindCommandBuilder.new(view)
|
62
|
-
#
|
63
|
-
# @param [ Collection::View ] view The collection view.
|
64
|
-
# @param [ Session ] session The session.
|
65
|
-
#
|
66
|
-
# @since 2.2.2
|
67
|
-
def initialize(view, session)
|
68
|
-
@view = view
|
69
|
-
@session = session
|
70
|
-
end
|
71
|
-
|
72
|
-
def_delegators :@view, :collection, :database, :filter, :options, :read
|
73
|
-
|
74
|
-
# Get the specification to pass to the find command operation.
|
75
|
-
#
|
76
|
-
# @example Get the specification.
|
77
|
-
# builder.specification
|
78
|
-
#
|
79
|
-
# @return [ Hash ] The specification.
|
80
|
-
#
|
81
|
-
# @since 2.2.0
|
82
|
-
def specification
|
83
|
-
{
|
84
|
-
selector: find_command,
|
85
|
-
db_name: database.name,
|
86
|
-
read: read,
|
87
|
-
session: @session,
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
# Get the specification for an explain command that wraps the find
|
92
|
-
# command.
|
93
|
-
#
|
94
|
-
# @example Get the explain spec.
|
95
|
-
# builder.explain_specification
|
96
|
-
#
|
97
|
-
# @return [ Hash ] The specification.
|
98
|
-
#
|
99
|
-
# @since 2.2.0
|
100
|
-
def explain_specification
|
101
|
-
{
|
102
|
-
selector: {
|
103
|
-
explain: find_command,
|
104
|
-
},
|
105
|
-
db_name: database.name,
|
106
|
-
read: read,
|
107
|
-
session: @session,
|
108
|
-
# We should always have options{:explain] set if we are explaining.
|
109
|
-
# The explain field is not sent to the server, it will be
|
110
|
-
# processed in the operation layer.
|
111
|
-
explain: options[:explain],
|
112
|
-
}
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def find_command
|
118
|
-
document = BSON::Document.new(
|
119
|
-
find: collection.name,
|
120
|
-
filter: filter,
|
121
|
-
)
|
122
|
-
if collection.read_concern
|
123
|
-
document[:readConcern] = Options::Mapper.transform_values_to_strings(
|
124
|
-
collection.read_concern)
|
125
|
-
end
|
126
|
-
command = Options::Mapper.transform_documents(
|
127
|
-
convert_flags(options), MAPPINGS, document)
|
128
|
-
if command['oplogReplay']
|
129
|
-
log_warn("oplogReplay is deprecated and ignored by MongoDB 4.4 and later")
|
130
|
-
end
|
131
|
-
convert_limit_and_batch_size(command)
|
132
|
-
command
|
133
|
-
end
|
134
|
-
|
135
|
-
def convert_limit_and_batch_size(command)
|
136
|
-
if command[:limit] && command[:limit] < 0 &&
|
137
|
-
command[:batchSize] && command[:batchSize] < 0
|
138
|
-
|
139
|
-
command[:limit] = command[:limit].abs
|
140
|
-
command[:batchSize] = command[:limit].abs
|
141
|
-
command[:singleBatch] = true
|
142
|
-
|
143
|
-
else
|
144
|
-
[:limit, :batchSize].each do |opt|
|
145
|
-
if command[opt]
|
146
|
-
if command[opt] < 0
|
147
|
-
command[opt] = command[opt].abs
|
148
|
-
command[:singleBatch] = true
|
149
|
-
elsif command[opt] == 0
|
150
|
-
command.delete(opt)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def convert_flags(options)
|
158
|
-
return options if options.empty?
|
159
|
-
opts = options.dup
|
160
|
-
opts.delete(:cursor_type)
|
161
|
-
Flags.map_flags(options).reduce(opts) do |o, key|
|
162
|
-
o.merge!(key => true)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def log_warn(*args)
|
167
|
-
database.client.log_warn(*args)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2015-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Collection
|
20
|
-
class View
|
21
|
-
module Builder
|
22
|
-
|
23
|
-
# Builds a legacy OP_QUERY specification from options.
|
24
|
-
#
|
25
|
-
# @since 2.2.0
|
26
|
-
class OpQuery
|
27
|
-
extend Forwardable
|
28
|
-
|
29
|
-
def_delegators :@view, :cluster, :collection, :database, :filter, :options, :read
|
30
|
-
|
31
|
-
# @return [ BSON::Document ] modifiers The server modifiers.
|
32
|
-
attr_reader :modifiers
|
33
|
-
|
34
|
-
# Create the new legacy query builder.
|
35
|
-
#
|
36
|
-
# @example Create the query builder.
|
37
|
-
# QueryBuilder.new(view)
|
38
|
-
#
|
39
|
-
# @param [ Collection::View ] view The collection view.
|
40
|
-
#
|
41
|
-
# @since 2.2.2
|
42
|
-
def initialize(view)
|
43
|
-
@view = view
|
44
|
-
@modifiers = Modifiers.map_server_modifiers(options)
|
45
|
-
end
|
46
|
-
|
47
|
-
def specification
|
48
|
-
{
|
49
|
-
:selector => requires_special_filter? ? special_filter : filter,
|
50
|
-
:read => read,
|
51
|
-
:options => query_options,
|
52
|
-
:db_name => database.name,
|
53
|
-
:coll_name => collection.name
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def query_options
|
60
|
-
BSON::Document.new(
|
61
|
-
project: options[:projection],
|
62
|
-
skip: options[:skip],
|
63
|
-
limit: options[:limit],
|
64
|
-
flags: Flags.map_flags(options),
|
65
|
-
batch_size: options[:batch_size]
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
|
-
def requires_special_filter?
|
70
|
-
!modifiers.empty? || cluster.sharded?
|
71
|
-
end
|
72
|
-
|
73
|
-
def read_pref_formatted
|
74
|
-
@read_formatted ||= begin
|
75
|
-
if read
|
76
|
-
read_pref = ServerSelector.get(read).to_mongos
|
77
|
-
Mongo::Lint.validate_camel_case_read_preference(read_pref)
|
78
|
-
read_pref
|
79
|
-
else
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def special_filter
|
86
|
-
sel = BSON::Document.new(:$query => filter).merge!(modifiers)
|
87
|
-
sel[:$readPreference] = read_pref_formatted unless read_pref_formatted.nil?
|
88
|
-
sel
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2015-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Cursor
|
20
|
-
module Builder
|
21
|
-
|
22
|
-
# Generates a specification for a get more command.
|
23
|
-
#
|
24
|
-
# @since 2.2.0
|
25
|
-
class GetMoreCommand
|
26
|
-
extend Forwardable
|
27
|
-
|
28
|
-
# @return [ Cursor ] cursor The cursor.
|
29
|
-
attr_reader :cursor
|
30
|
-
|
31
|
-
def_delegators :@cursor, :collection_name, :database, :view
|
32
|
-
def_delegators :view, :batch_size
|
33
|
-
|
34
|
-
# Create the new builder.
|
35
|
-
#
|
36
|
-
# @example Create the builder.
|
37
|
-
# GetMoreCommand.new(cursor)
|
38
|
-
#
|
39
|
-
# @param [ Cursor ] cursor The cursor.
|
40
|
-
# @param [ Session ] session The session.
|
41
|
-
#
|
42
|
-
# @since 2.2.0
|
43
|
-
def initialize(cursor, session = nil)
|
44
|
-
@cursor = cursor
|
45
|
-
@session = session
|
46
|
-
end
|
47
|
-
|
48
|
-
# Get the specification.
|
49
|
-
#
|
50
|
-
# @example Get the specification.
|
51
|
-
# get_more_command.specification
|
52
|
-
#
|
53
|
-
# @return [ Hash ] The spec.
|
54
|
-
#
|
55
|
-
# @since 2.2.0
|
56
|
-
def specification
|
57
|
-
{ selector: get_more_command, db_name: database.name, session: @session }
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def get_more_command
|
63
|
-
command = {
|
64
|
-
:getMore => BSON::Int64.new(cursor.id),
|
65
|
-
:collection => collection_name,
|
66
|
-
}
|
67
|
-
command[:batchSize] = batch_size.abs if batch_size && batch_size != 0
|
68
|
-
# If the max_await_time_ms option is set, then we set maxTimeMS on
|
69
|
-
# the get more command.
|
70
|
-
if view.respond_to?(:max_await_time_ms)
|
71
|
-
if view.max_await_time_ms && view.options[:await_data]
|
72
|
-
command[:maxTimeMS] = view.max_await_time_ms
|
73
|
-
end
|
74
|
-
end
|
75
|
-
command
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2015-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Cursor
|
20
|
-
module Builder
|
21
|
-
|
22
|
-
# Generates a specification for a kill cursors command.
|
23
|
-
#
|
24
|
-
# @since 2.2.0
|
25
|
-
class KillCursorsCommand
|
26
|
-
extend Forwardable
|
27
|
-
|
28
|
-
# @return [ Cursor ] cursor The cursor.
|
29
|
-
attr_reader :cursor
|
30
|
-
|
31
|
-
def_delegators :@cursor, :collection_name, :database
|
32
|
-
|
33
|
-
# Create the new builder.
|
34
|
-
#
|
35
|
-
# @example Create the builder.
|
36
|
-
# KillCursorsCommand.new(cursor)
|
37
|
-
#
|
38
|
-
# @param [ Cursor ] cursor The cursor.
|
39
|
-
#
|
40
|
-
# @since 2.2.0
|
41
|
-
def initialize(cursor)
|
42
|
-
@cursor = cursor
|
43
|
-
end
|
44
|
-
|
45
|
-
# Get the specification.
|
46
|
-
#
|
47
|
-
# @example Get the specification.
|
48
|
-
# kill_cursors_command.specification
|
49
|
-
#
|
50
|
-
# @return [ Hash ] The spec.
|
51
|
-
#
|
52
|
-
# @since 2.2.0
|
53
|
-
def specification
|
54
|
-
{ selector: kill_cursors_command, db_name: database.name }
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def kill_cursors_command
|
60
|
-
{
|
61
|
-
killCursors: collection_name,
|
62
|
-
cursors: [ BSON::Int64.new(cursor.id) ],
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
class << self
|
67
|
-
|
68
|
-
# Update a specification's list of cursor ids.
|
69
|
-
#
|
70
|
-
# @example Update a specification's list of cursor ids.
|
71
|
-
# KillCursorsCommand.update_cursors(spec, ids)
|
72
|
-
#
|
73
|
-
# @return [ Hash ] The specification.
|
74
|
-
# @return [ Array<Integer> ] The ids to update with.
|
75
|
-
#
|
76
|
-
# @since 2.3.0
|
77
|
-
def update_cursors(spec, ids)
|
78
|
-
# Ruby 2.5+ can & BSON::Int64 instances.
|
79
|
-
# Ruby 2.4 and earlier cannot.
|
80
|
-
# Convert stored ids to Ruby integers for compatibility with
|
81
|
-
# older Rubies.
|
82
|
-
ids = get_cursors_list(spec) & ids
|
83
|
-
ids = ids.map do |cursor_id|
|
84
|
-
BSON::Int64.new(cursor_id)
|
85
|
-
end
|
86
|
-
spec[:selector].merge!(cursors: ids)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Get the list of cursor ids from a spec generated by this Builder.
|
90
|
-
#
|
91
|
-
# @example Get the list of cursor ids.
|
92
|
-
# KillCursorsCommand.cursors(spec)
|
93
|
-
#
|
94
|
-
# @return [ Array<Integer> ] The cursor ids.
|
95
|
-
#
|
96
|
-
# @since 2.3.0
|
97
|
-
def get_cursors_list(spec)
|
98
|
-
spec[:selector][:cursors].map do |value|
|
99
|
-
if value.respond_to?(:value)
|
100
|
-
# bson-ruby >= 4.6.0
|
101
|
-
value = value.value
|
102
|
-
else
|
103
|
-
value = value.instance_variable_get('@integer')
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2015-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Cursor
|
20
|
-
module Builder
|
21
|
-
|
22
|
-
# Encapsulates behavior around generating an OP_GET_MORE specification.
|
23
|
-
#
|
24
|
-
# @since 2.2.0
|
25
|
-
class OpGetMore
|
26
|
-
extend Forwardable
|
27
|
-
|
28
|
-
# @return [ Cursor ] cursor The cursor.
|
29
|
-
attr_reader :cursor
|
30
|
-
|
31
|
-
def_delegators :@cursor, :collection_name, :database, :to_return
|
32
|
-
|
33
|
-
# Create the new builder.
|
34
|
-
#
|
35
|
-
# @example Create the builder.
|
36
|
-
# OpGetMore.new(cursor)
|
37
|
-
#
|
38
|
-
# @param [ Cursor ] cursor The cursor.
|
39
|
-
#
|
40
|
-
# @since 2.2.0
|
41
|
-
def initialize(cursor)
|
42
|
-
@cursor = cursor
|
43
|
-
end
|
44
|
-
|
45
|
-
# Get the specification.
|
46
|
-
#
|
47
|
-
# @example Get the specification.
|
48
|
-
# op_get_more.specification
|
49
|
-
#
|
50
|
-
# @return [ Hash ] The specification.
|
51
|
-
#
|
52
|
-
# @since 2.2.0
|
53
|
-
def specification
|
54
|
-
{
|
55
|
-
:to_return => to_return,
|
56
|
-
:cursor_id => BSON::Int64.new(cursor.id),
|
57
|
-
:db_name => database.name,
|
58
|
-
:coll_name => collection_name,
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2015-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Cursor
|
20
|
-
module Builder
|
21
|
-
|
22
|
-
# Encapsulates behavior around generating an OP_KILL_CURSORS specification.
|
23
|
-
#
|
24
|
-
# @since 2.2.0
|
25
|
-
class OpKillCursors
|
26
|
-
extend Forwardable
|
27
|
-
|
28
|
-
# @return [ Cursor ] cursor The cursor.
|
29
|
-
attr_reader :cursor
|
30
|
-
|
31
|
-
def_delegators :@cursor, :collection_name, :database
|
32
|
-
|
33
|
-
# Create the new builder.
|
34
|
-
#
|
35
|
-
# @example Create the builder.
|
36
|
-
# OpKillCursors.new(cursor)
|
37
|
-
#
|
38
|
-
# @param [ Cursor ] cursor The cursor.
|
39
|
-
#
|
40
|
-
# @since 2.2.0
|
41
|
-
def initialize(cursor)
|
42
|
-
@cursor = cursor
|
43
|
-
end
|
44
|
-
|
45
|
-
# Get the specification.
|
46
|
-
#
|
47
|
-
# @example Get the specification.
|
48
|
-
# op_kill_cursors.specification
|
49
|
-
#
|
50
|
-
# @return [ Hash ] The specification.
|
51
|
-
#
|
52
|
-
# @since 2.2.0
|
53
|
-
def specification
|
54
|
-
{
|
55
|
-
coll_name: collection_name,
|
56
|
-
db_name: database.name,
|
57
|
-
cursor_ids: [ BSON::Int64.new(cursor.id) ],
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
class << self
|
62
|
-
|
63
|
-
# Update a specification's list of cursor ids.
|
64
|
-
#
|
65
|
-
# @example Update a specification's list of cursor ids.
|
66
|
-
# OpKillCursors.update_cursors(spec, ids)
|
67
|
-
#
|
68
|
-
# @return [ Hash ] The specification.
|
69
|
-
# @return [ Array<Integer> ] The ids to update with.
|
70
|
-
#
|
71
|
-
# @since 2.3.0
|
72
|
-
def update_cursors(spec, ids)
|
73
|
-
# Ruby 2.5+ can & BSON::Int64 instances.
|
74
|
-
# Ruby 2.4 and earlier cannot.
|
75
|
-
# Convert stored ids to Ruby integers for compatibility with
|
76
|
-
# older Rubies.
|
77
|
-
ids = get_cursors_list(spec) & ids
|
78
|
-
ids = ids.map do |cursor_id|
|
79
|
-
BSON::Int64.new(cursor_id)
|
80
|
-
end
|
81
|
-
spec.merge!(cursor_ids: ids)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Get the list of cursor ids from a spec generated by this Builder.
|
85
|
-
#
|
86
|
-
# @example Get the list of cursor ids.
|
87
|
-
# OpKillCursors.cursors(spec)
|
88
|
-
#
|
89
|
-
# @return [ Array<Integer> ] The cursor ids.
|
90
|
-
#
|
91
|
-
# @since 2.3.0
|
92
|
-
def get_cursors_list(spec)
|
93
|
-
spec[:cursor_ids].map do |value|
|
94
|
-
if value.respond_to?(:value)
|
95
|
-
# bson-ruby >= 4.6.0
|
96
|
-
value.value
|
97
|
-
else
|
98
|
-
value.instance_variable_get('@integer')
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/lib/mongo/server/context.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# Copyright (C) 2014-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the 'License');
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an 'AS IS' BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
module Mongo
|
19
|
-
class Server
|
20
|
-
|
21
|
-
# Represents a context in which messages are sent to the server on a
|
22
|
-
# connection.
|
23
|
-
#
|
24
|
-
# @since 2.0.0
|
25
|
-
#
|
26
|
-
# @deprecated Will be removed in version 3.0
|
27
|
-
class Context
|
28
|
-
extend Forwardable
|
29
|
-
|
30
|
-
# Instantiate a server context.
|
31
|
-
#
|
32
|
-
# @example Instantiate a server context.
|
33
|
-
# Mongo::Server::Context.new(server)
|
34
|
-
#
|
35
|
-
# @param [ Mongo::Server ] server The server the context is for.
|
36
|
-
#
|
37
|
-
# @since 2.0.0
|
38
|
-
def initialize(server)
|
39
|
-
@server = server
|
40
|
-
end
|
41
|
-
|
42
|
-
# @return [ Mongo::Server ] server The server the context is for.
|
43
|
-
attr_reader :server
|
44
|
-
|
45
|
-
# Delegate state checks to the server.
|
46
|
-
def_delegators :@server,
|
47
|
-
:cluster,
|
48
|
-
:features,
|
49
|
-
:max_wire_version,
|
50
|
-
:max_write_batch_size,
|
51
|
-
:mongos?,
|
52
|
-
:primary?,
|
53
|
-
:secondary?,
|
54
|
-
:standalone?
|
55
|
-
|
56
|
-
# Execute a block of code with a connection, that is checked out of the
|
57
|
-
# pool and then checked back in.
|
58
|
-
#
|
59
|
-
# @example Send a message with the connection.
|
60
|
-
# context.with_connection do |connection|
|
61
|
-
# connection.dispatch([ command ])
|
62
|
-
# end
|
63
|
-
#
|
64
|
-
# @return [ Object ] The result of the block execution.
|
65
|
-
#
|
66
|
-
# @since 2.0.0
|
67
|
-
def with_connection(&block)
|
68
|
-
server.pool.with_connection(&block)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|