mongo 2.6.4 → 2.7.0.rc0
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.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/Rakefile +10 -11
- data/lib/mongo.rb +3 -1
- data/lib/mongo/active_support.rb +17 -0
- data/lib/mongo/address.rb +47 -39
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +1 -1
- data/lib/mongo/address/unix.rb +1 -1
- data/lib/mongo/auth.rb +3 -8
- data/lib/mongo/auth/cr.rb +2 -2
- data/lib/mongo/auth/cr/conversation.rb +4 -4
- data/lib/mongo/auth/ldap.rb +2 -2
- data/lib/mongo/auth/ldap/conversation.rb +3 -3
- data/lib/mongo/auth/roles.rb +1 -1
- data/lib/mongo/auth/scram.rb +2 -2
- data/lib/mongo/auth/scram/conversation.rb +5 -5
- data/lib/mongo/auth/stringprep.rb +1 -1
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +1 -1
- data/lib/mongo/auth/stringprep/tables.rb +1 -1
- data/lib/mongo/auth/user.rb +1 -1
- data/lib/mongo/auth/user/view.rb +2 -2
- data/lib/mongo/auth/x509.rb +2 -2
- data/lib/mongo/auth/x509/conversation.rb +3 -3
- data/lib/mongo/bson.rb +1 -1
- data/lib/mongo/bulk_write.rb +1 -1
- data/lib/mongo/bulk_write/combineable.rb +2 -2
- data/lib/mongo/bulk_write/ordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/result.rb +1 -1
- data/lib/mongo/bulk_write/result_combiner.rb +1 -1
- data/lib/mongo/bulk_write/transformable.rb +2 -2
- data/lib/mongo/bulk_write/unordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/validatable.rb +2 -2
- data/lib/mongo/client.rb +194 -82
- data/lib/mongo/cluster.rb +418 -298
- data/lib/mongo/cluster/periodic_executor.rb +10 -3
- data/lib/mongo/cluster/reapers/socket_reaper.rb +1 -1
- data/lib/mongo/cluster/sdam_flow.rb +481 -0
- data/lib/mongo/cluster/topology.rb +37 -16
- data/lib/mongo/cluster/topology/base.rb +218 -0
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +34 -0
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +168 -0
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +27 -0
- data/lib/mongo/cluster/topology/sharded.rb +12 -115
- data/lib/mongo/cluster/topology/single.rb +18 -112
- data/lib/mongo/cluster/topology/unknown.rb +11 -152
- data/lib/mongo/collection.rb +2 -2
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +2 -2
- data/lib/mongo/collection/view/builder.rb +1 -1
- data/lib/mongo/collection/view/builder/aggregation.rb +1 -1
- data/lib/mongo/collection/view/builder/find_command.rb +1 -1
- data/lib/mongo/collection/view/builder/flags.rb +2 -2
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/builder/modifiers.rb +2 -2
- data/lib/mongo/collection/view/builder/op_query.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +4 -3
- data/lib/mongo/collection/view/change_stream/retryable.rb +1 -1
- data/lib/mongo/collection/view/explainable.rb +2 -2
- data/lib/mongo/collection/view/immutable.rb +2 -2
- data/lib/mongo/collection/view/iterable.rb +2 -2
- data/lib/mongo/collection/view/map_reduce.rb +2 -2
- data/lib/mongo/collection/view/readable.rb +3 -3
- data/lib/mongo/collection/view/writable.rb +2 -2
- data/lib/mongo/cursor.rb +8 -6
- data/lib/mongo/cursor/builder.rb +1 -1
- data/lib/mongo/cursor/builder/get_more_command.rb +1 -1
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +1 -1
- data/lib/mongo/cursor/builder/op_get_more.rb +2 -2
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +2 -2
- data/lib/mongo/database.rb +9 -4
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/dbref.rb +1 -1
- data/lib/mongo/error.rb +15 -2
- data/lib/mongo/error/bulk_write_error.rb +17 -1
- data/lib/mongo/error/change_stream_resumable.rb +1 -1
- data/lib/mongo/error/closed_stream.rb +1 -1
- data/lib/mongo/error/extra_file_chunk.rb +1 -1
- data/lib/mongo/error/file_not_found.rb +1 -1
- data/lib/mongo/error/handshake_error.rb +24 -0
- data/lib/mongo/error/insufficient_iteration_count.rb +1 -1
- data/lib/mongo/error/invalid_application_name.rb +1 -1
- data/lib/mongo/error/invalid_bulk_operation.rb +1 -1
- data/lib/mongo/error/invalid_bulk_operation_type.rb +1 -1
- data/lib/mongo/error/invalid_collection_name.rb +1 -1
- data/lib/mongo/error/invalid_database_name.rb +1 -1
- data/lib/mongo/error/invalid_document.rb +1 -1
- data/lib/mongo/error/invalid_file.rb +1 -1
- data/lib/mongo/error/invalid_file_revision.rb +1 -1
- data/lib/mongo/error/invalid_min_pool_size.rb +1 -1
- data/lib/mongo/error/invalid_nonce.rb +1 -1
- data/lib/mongo/error/invalid_read_option.rb +1 -1
- data/lib/mongo/error/invalid_replacement_document.rb +1 -1
- data/lib/mongo/error/invalid_server_preference.rb +1 -1
- data/lib/mongo/error/invalid_session.rb +1 -1
- data/lib/mongo/error/invalid_signature.rb +1 -1
- data/lib/mongo/error/invalid_transaction_operation.rb +2 -2
- data/lib/mongo/error/invalid_txt_record.rb +1 -1
- data/lib/mongo/error/invalid_update_document.rb +1 -1
- data/lib/mongo/error/invalid_uri.rb +1 -1
- data/lib/mongo/error/invalid_write_concern.rb +1 -1
- data/lib/mongo/error/lint_error.rb +1 -1
- data/lib/mongo/error/max_bson_size.rb +1 -1
- data/lib/mongo/error/max_message_size.rb +1 -1
- data/lib/mongo/error/mismatched_domain.rb +1 -1
- data/lib/mongo/error/missing_file_chunk.rb +1 -1
- data/lib/mongo/error/missing_resume_token.rb +1 -1
- data/lib/mongo/error/multi_index_drop.rb +1 -1
- data/lib/mongo/error/need_primary_server.rb +1 -1
- data/lib/mongo/error/no_server_available.rb +9 -5
- data/lib/mongo/error/no_srv_records.rb +1 -1
- data/lib/mongo/error/operation_failure.rb +2 -1
- data/lib/mongo/error/parser.rb +10 -1
- data/lib/mongo/error/session_ended.rb +27 -0
- data/lib/mongo/error/socket_error.rb +1 -1
- data/lib/mongo/error/socket_timeout_error.rb +1 -1
- data/lib/mongo/error/unchangeable_collection_option.rb +1 -1
- data/lib/mongo/error/unexpected_chunk_length.rb +1 -1
- data/lib/mongo/error/unexpected_response.rb +1 -1
- data/lib/mongo/error/unknown_payload_type.rb +1 -1
- data/lib/mongo/error/unsupported_array_filters.rb +1 -1
- data/lib/mongo/error/unsupported_collation.rb +1 -1
- data/lib/mongo/error/unsupported_features.rb +1 -1
- data/lib/mongo/error/unsupported_message_type.rb +1 -1
- data/lib/mongo/error/write_retryable.rb +1 -1
- data/lib/mongo/event.rb +3 -4
- data/lib/mongo/event/base.rb +6 -3
- data/lib/mongo/event/description_changed.rb +7 -27
- data/lib/mongo/event/listeners.rb +1 -1
- data/lib/mongo/event/publisher.rb +1 -1
- data/lib/mongo/event/subscriber.rb +1 -1
- data/lib/mongo/grid.rb +1 -1
- data/lib/mongo/grid/file.rb +1 -1
- data/lib/mongo/grid/file/chunk.rb +2 -2
- data/lib/mongo/grid/file/info.rb +8 -2
- data/lib/mongo/grid/fs_bucket.rb +1 -1
- data/lib/mongo/grid/stream.rb +1 -1
- data/lib/mongo/grid/stream/read.rb +1 -1
- data/lib/mongo/grid/stream/write.rb +1 -1
- data/lib/mongo/id.rb +64 -0
- data/lib/mongo/index.rb +1 -1
- data/lib/mongo/index/view.rb +1 -1
- data/lib/mongo/lint.rb +44 -5
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/logger.rb +1 -1
- data/lib/mongo/monitoring.rb +34 -10
- data/lib/mongo/monitoring/command_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/event.rb +4 -1
- data/lib/mongo/monitoring/event/command_failed.rb +1 -1
- data/lib/mongo/monitoring/event/command_started.rb +2 -2
- data/lib/mongo/monitoring/event/command_succeeded.rb +1 -1
- data/lib/mongo/monitoring/event/secure.rb +2 -2
- data/lib/mongo/monitoring/event/server_closed.rb +14 -1
- data/lib/mongo/monitoring/event/server_description_changed.rb +16 -1
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +71 -0
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +55 -0
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +63 -0
- data/lib/mongo/monitoring/event/server_opening.rb +8 -4
- data/lib/mongo/monitoring/event/topology_changed.rb +9 -6
- data/lib/mongo/monitoring/event/topology_closed.rb +14 -1
- data/lib/mongo/monitoring/event/topology_opening.rb +8 -4
- data/lib/mongo/monitoring/publishable.rb +3 -35
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +4 -4
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +30 -0
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +2 -2
- data/lib/mongo/operation.rb +8 -0
- data/lib/mongo/operation/aggregate.rb +3 -20
- data/lib/mongo/operation/aggregate/command.rb +1 -1
- data/lib/mongo/operation/aggregate/op_msg.rb +4 -30
- data/lib/mongo/operation/aggregate/result.rb +2 -2
- data/lib/mongo/operation/collections_info.rb +1 -1
- data/lib/mongo/operation/collections_info/result.rb +2 -2
- data/lib/mongo/operation/command.rb +2 -19
- data/lib/mongo/operation/command/command.rb +1 -1
- data/lib/mongo/operation/command/op_msg.rb +2 -27
- data/lib/mongo/operation/count.rb +2 -19
- data/lib/mongo/operation/count/command.rb +1 -1
- data/lib/mongo/operation/count/op_msg.rb +2 -11
- data/lib/mongo/operation/create.rb +2 -19
- data/lib/mongo/operation/create/command.rb +1 -1
- data/lib/mongo/operation/create/op_msg.rb +3 -20
- data/lib/mongo/operation/create_index.rb +2 -19
- data/lib/mongo/operation/create_index/command.rb +1 -1
- data/lib/mongo/operation/create_index/op_msg.rb +3 -18
- data/lib/mongo/operation/create_user.rb +2 -19
- data/lib/mongo/operation/create_user/command.rb +1 -1
- data/lib/mongo/operation/create_user/op_msg.rb +3 -18
- data/lib/mongo/operation/delete.rb +1 -1
- data/lib/mongo/operation/delete/bulk_result.rb +2 -2
- data/lib/mongo/operation/delete/command.rb +1 -1
- data/lib/mongo/operation/delete/legacy.rb +1 -1
- data/lib/mongo/operation/delete/op_msg.rb +5 -23
- data/lib/mongo/operation/delete/result.rb +2 -2
- data/lib/mongo/operation/distinct.rb +2 -19
- data/lib/mongo/operation/distinct/command.rb +1 -1
- data/lib/mongo/operation/distinct/op_msg.rb +3 -20
- data/lib/mongo/operation/drop.rb +2 -19
- data/lib/mongo/operation/drop/command.rb +1 -1
- data/lib/mongo/operation/drop/op_msg.rb +3 -20
- data/lib/mongo/operation/drop_database.rb +2 -19
- data/lib/mongo/operation/drop_database/command.rb +1 -1
- data/lib/mongo/operation/drop_database/op_msg.rb +3 -20
- data/lib/mongo/operation/drop_index.rb +2 -19
- data/lib/mongo/operation/drop_index/command.rb +1 -1
- data/lib/mongo/operation/drop_index/op_msg.rb +3 -18
- data/lib/mongo/operation/explain.rb +2 -21
- data/lib/mongo/operation/explain/command.rb +1 -1
- data/lib/mongo/operation/explain/legacy.rb +1 -1
- data/lib/mongo/operation/explain/op_msg.rb +4 -30
- data/lib/mongo/operation/explain/result.rb +2 -2
- data/lib/mongo/operation/find.rb +2 -21
- data/lib/mongo/operation/find/command.rb +1 -1
- data/lib/mongo/operation/find/legacy.rb +1 -1
- data/lib/mongo/operation/find/legacy/result.rb +2 -2
- data/lib/mongo/operation/find/op_msg.rb +6 -30
- data/lib/mongo/operation/find/result.rb +2 -2
- data/lib/mongo/operation/get_more.rb +2 -11
- data/lib/mongo/operation/get_more/command.rb +1 -1
- data/lib/mongo/operation/get_more/legacy.rb +1 -1
- data/lib/mongo/operation/get_more/op_msg.rb +6 -30
- data/lib/mongo/operation/get_more/result.rb +2 -2
- data/lib/mongo/operation/indexes.rb +2 -21
- data/lib/mongo/operation/indexes/command.rb +1 -1
- data/lib/mongo/operation/indexes/legacy.rb +1 -1
- data/lib/mongo/operation/indexes/op_msg.rb +4 -30
- data/lib/mongo/operation/indexes/result.rb +2 -2
- data/lib/mongo/operation/insert.rb +1 -1
- data/lib/mongo/operation/insert/bulk_result.rb +2 -2
- data/lib/mongo/operation/insert/command.rb +1 -1
- data/lib/mongo/operation/insert/legacy.rb +1 -1
- data/lib/mongo/operation/insert/op_msg.rb +10 -23
- data/lib/mongo/operation/insert/result.rb +2 -2
- data/lib/mongo/operation/kill_cursors.rb +2 -21
- data/lib/mongo/operation/kill_cursors/command.rb +1 -1
- data/lib/mongo/operation/kill_cursors/legacy.rb +1 -1
- data/lib/mongo/operation/kill_cursors/op_msg.rb +3 -20
- data/lib/mongo/operation/list_collections.rb +2 -19
- data/lib/mongo/operation/list_collections/command.rb +1 -1
- data/lib/mongo/operation/list_collections/op_msg.rb +4 -28
- data/lib/mongo/operation/list_collections/result.rb +2 -2
- data/lib/mongo/operation/map_reduce.rb +2 -19
- data/lib/mongo/operation/map_reduce/command.rb +1 -1
- data/lib/mongo/operation/map_reduce/op_msg.rb +4 -30
- data/lib/mongo/operation/map_reduce/result.rb +2 -2
- data/lib/mongo/operation/op_msg_base.rb +30 -0
- data/lib/mongo/operation/parallel_scan.rb +2 -19
- data/lib/mongo/operation/parallel_scan/command.rb +1 -1
- data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -28
- data/lib/mongo/operation/parallel_scan/result.rb +2 -2
- data/lib/mongo/operation/remove_user.rb +2 -19
- data/lib/mongo/operation/remove_user/command.rb +1 -1
- data/lib/mongo/operation/remove_user/op_msg.rb +3 -18
- data/lib/mongo/operation/result.rb +14 -2
- data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -1
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +14 -6
- data/lib/mongo/operation/shared/executable.rb +10 -3
- data/lib/mongo/operation/shared/executable_no_validate.rb +30 -0
- data/lib/mongo/operation/shared/executable_transaction_label.rb +34 -0
- data/lib/mongo/operation/shared/idable.rb +1 -1
- data/lib/mongo/operation/shared/limited.rb +1 -1
- data/lib/mongo/operation/shared/object_id_generator.rb +1 -1
- data/lib/mongo/operation/shared/op_msg_or_command.rb +42 -0
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +45 -0
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +45 -0
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +33 -0
- data/lib/mongo/operation/shared/polymorphic_result.rb +32 -0
- data/lib/mongo/operation/shared/read_preference_supported.rb +1 -1
- data/lib/mongo/operation/shared/result/aggregatable.rb +2 -2
- data/lib/mongo/operation/shared/sessions_supported.rb +24 -4
- data/lib/mongo/operation/shared/specifiable.rb +5 -3
- data/lib/mongo/operation/shared/write.rb +1 -1
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -1
- data/lib/mongo/operation/update.rb +1 -1
- data/lib/mongo/operation/update/bulk_result.rb +2 -2
- data/lib/mongo/operation/update/command.rb +1 -1
- data/lib/mongo/operation/update/legacy.rb +1 -1
- data/lib/mongo/operation/update/legacy/result.rb +2 -2
- data/lib/mongo/operation/update/op_msg.rb +5 -23
- data/lib/mongo/operation/update/result.rb +2 -2
- data/lib/mongo/operation/update_user.rb +2 -19
- data/lib/mongo/operation/update_user/command.rb +1 -1
- data/lib/mongo/operation/update_user/op_msg.rb +3 -18
- data/lib/mongo/operation/users_info.rb +2 -19
- data/lib/mongo/operation/users_info/command.rb +1 -1
- data/lib/mongo/operation/users_info/op_msg.rb +4 -28
- data/lib/mongo/operation/users_info/result.rb +2 -2
- data/lib/mongo/options.rb +1 -1
- data/lib/mongo/options/mapper.rb +10 -3
- data/lib/mongo/options/redacted.rb +1 -1
- data/lib/mongo/protocol/bit_vector.rb +1 -1
- data/lib/mongo/protocol/compressed.rb +2 -2
- data/lib/mongo/protocol/delete.rb +1 -1
- data/lib/mongo/protocol/get_more.rb +1 -1
- data/lib/mongo/protocol/insert.rb +1 -1
- data/lib/mongo/protocol/kill_cursors.rb +1 -1
- data/lib/mongo/protocol/message.rb +4 -9
- data/lib/mongo/protocol/msg.rb +2 -2
- data/lib/mongo/protocol/query.rb +1 -1
- data/lib/mongo/protocol/registry.rb +1 -1
- data/lib/mongo/protocol/reply.rb +1 -1
- data/lib/mongo/protocol/serializers.rb +1 -1
- data/lib/mongo/protocol/update.rb +1 -1
- data/lib/mongo/retryable.rb +40 -14
- data/lib/mongo/semaphore.rb +46 -0
- data/lib/mongo/server.rb +159 -44
- data/lib/mongo/{cluster → server}/app_metadata.rb +26 -13
- data/lib/mongo/server/connectable.rb +9 -13
- data/lib/mongo/server/connection.rb +143 -71
- data/lib/mongo/server/connection_pool.rb +25 -20
- data/lib/mongo/server/connection_pool/queue.rb +163 -46
- data/lib/mongo/server/context.rb +13 -13
- data/lib/mongo/server/description.rb +93 -48
- data/lib/mongo/server/description/features.rb +22 -3
- data/lib/mongo/server/monitor.rb +143 -74
- data/lib/mongo/server/monitor/app_metadata.rb +34 -0
- data/lib/mongo/server/monitor/connection.rb +42 -26
- data/lib/mongo/server/round_trip_time_averager.rb +64 -0
- data/lib/mongo/server_selector.rb +1 -1
- data/lib/mongo/server_selector/nearest.rb +1 -1
- data/lib/mongo/server_selector/primary.rb +1 -1
- data/lib/mongo/server_selector/primary_preferred.rb +1 -1
- data/lib/mongo/server_selector/secondary.rb +1 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
- data/lib/mongo/server_selector/selectable.rb +38 -13
- data/lib/mongo/session.rb +189 -40
- data/lib/mongo/session/server_session.rb +18 -7
- data/lib/mongo/session/session_pool.rb +1 -1
- data/lib/mongo/socket.rb +1 -1
- data/lib/mongo/socket/ssl.rb +46 -7
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/socket/unix.rb +1 -1
- data/lib/mongo/uri.rb +304 -18
- data/lib/mongo/uri/srv_protocol.rb +1 -1
- data/lib/mongo/version.rb +2 -2
- data/lib/mongo/write_concern.rb +6 -6
- data/lib/mongo/write_concern/acknowledged.rb +2 -4
- data/lib/mongo/write_concern/{normalizable.rb → base.rb} +5 -6
- data/lib/mongo/write_concern/unacknowledged.rb +2 -4
- data/mongo.gemspec +1 -1
- data/spec/enterprise_auth/kerberos_spec.rb +57 -0
- data/spec/integration/bulk_insert_spec.rb +4 -2
- data/spec/integration/change_stream_examples_spec.rb +5 -6
- data/spec/integration/change_stream_spec.rb +17 -14
- data/spec/integration/client_connectivity_spec.rb +38 -0
- data/spec/integration/client_construction_spec.rb +94 -0
- data/spec/integration/command_monitoring_spec.rb +18 -30
- data/spec/integration/connect_single_rs_name_spec.rb +67 -0
- data/spec/integration/connection_spec.rb +209 -0
- data/spec/integration/cursor_reaping_spec.rb +95 -0
- data/spec/integration/docs_examples_spec.rb +6 -5
- data/spec/integration/heartbeat_events_spec.rb +116 -0
- data/spec/integration/retryable_writes_spec.rb +18 -8
- data/spec/integration/sdam_events_spec.rb +47 -0
- data/spec/integration/server_description_spec.rb +48 -0
- data/spec/integration/time_zone_querying_spec.rb +52 -0
- data/spec/lite_spec_helper.rb +74 -19
- data/spec/mongo/address_spec.rb +17 -7
- data/spec/mongo/auth/cr_spec.rb +8 -5
- data/spec/mongo/auth/ldap_spec.rb +9 -6
- data/spec/mongo/auth/scram/conversation_spec.rb +4 -1
- data/spec/mongo/auth/scram/negotiation_spec.rb +68 -110
- data/spec/mongo/auth/scram_spec.rb +8 -5
- data/spec/mongo/auth/user/view_spec.rb +5 -5
- data/spec/mongo/auth/x509_spec.rb +9 -6
- data/spec/mongo/bulk_write_spec.rb +32 -22
- data/spec/mongo/client_construction_spec.rb +1164 -0
- data/spec/mongo/client_spec.rb +62 -1000
- data/spec/mongo/cluster/cursor_reaper_spec.rb +2 -2
- data/spec/mongo/cluster/topology/replica_set_spec.rb +186 -251
- data/spec/mongo/cluster/topology/sharded_spec.rb +48 -50
- data/spec/mongo/cluster/topology/single_spec.rb +62 -22
- data/spec/mongo/cluster/topology/unknown_spec.rb +30 -115
- data/spec/mongo/cluster/topology_spec.rb +111 -13
- data/spec/mongo/cluster_spec.rb +195 -246
- data/spec/mongo/collection/view/aggregation_spec.rb +7 -8
- data/spec/mongo/collection/view/change_stream_spec.rb +18 -7
- data/spec/mongo/collection/view/explainable_spec.rb +1 -1
- data/spec/mongo/collection/view/immutable_spec.rb +1 -1
- data/spec/mongo/collection/view/map_reduce_spec.rb +7 -8
- data/spec/mongo/collection/view/readable_spec.rb +7 -8
- data/spec/mongo/collection/view/writable_spec.rb +1 -1
- data/spec/mongo/collection/view_spec.rb +2 -5
- data/spec/mongo/collection_spec.rb +41 -48
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +1 -1
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +1 -1
- data/spec/mongo/cursor_spec.rb +51 -25
- data/spec/mongo/database_spec.rb +25 -37
- data/spec/mongo/error/no_server_available_spec.rb +22 -0
- data/spec/mongo/error/operation_failure_spec.rb +70 -0
- data/spec/mongo/error/parser_spec.rb +44 -10
- data/spec/mongo/grid/file/info_spec.rb +3 -3
- data/spec/mongo/grid/fs_bucket_spec.rb +18 -53
- data/spec/mongo/grid/stream/read_spec.rb +9 -15
- data/spec/mongo/grid/stream/write_spec.rb +11 -23
- data/spec/mongo/id_spec.rb +35 -0
- data/spec/mongo/index/view_spec.rb +11 -72
- data/spec/mongo/lint_spec.rb +76 -0
- data/spec/mongo/monitoring/event/command_failed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/command_started_spec.rb +1 -1
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +1 -1
- data/spec/mongo/monitoring/event/secure_spec.rb +1 -1
- data/spec/mongo/monitoring/event/server_closed_spec.rb +35 -0
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +31 -0
- data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +31 -0
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +31 -0
- data/spec/mongo/monitoring/event/server_opening_spec.rb +35 -0
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +41 -0
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +35 -0
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +35 -0
- data/spec/mongo/monitoring_spec.rb +2 -2
- data/spec/mongo/operation/aggregate_spec.rb +2 -2
- data/spec/mongo/operation/collections_info_spec.rb +2 -2
- data/spec/mongo/operation/command_spec.rb +1 -1
- data/spec/mongo/operation/create_index_spec.rb +8 -11
- data/spec/mongo/operation/create_user_spec.rb +6 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +21 -12
- data/spec/mongo/operation/delete/command_spec.rb +3 -2
- data/spec/mongo/operation/delete/op_msg_spec.rb +32 -17
- data/spec/mongo/operation/delete_spec.rb +21 -10
- data/spec/mongo/operation/drop_index_spec.rb +5 -2
- data/spec/mongo/operation/find/legacy_spec.rb +3 -2
- data/spec/mongo/operation/get_more_spec.rb +2 -2
- data/spec/mongo/operation/indexes_spec.rb +3 -2
- data/spec/mongo/operation/insert/bulk_spec.rb +13 -3
- data/spec/mongo/operation/insert/command_spec.rb +3 -2
- data/spec/mongo/operation/insert/op_msg_spec.rb +34 -18
- data/spec/mongo/operation/insert_spec.rb +7 -6
- data/spec/mongo/operation/kill_cursors_spec.rb +2 -2
- data/spec/mongo/operation/map_reduce_spec.rb +2 -2
- data/spec/mongo/operation/remove_user_spec.rb +6 -2
- data/spec/mongo/operation/result_spec.rb +6 -3
- data/spec/mongo/operation/update/bulk_spec.rb +3 -3
- data/spec/mongo/operation/update/command_spec.rb +8 -7
- data/spec/mongo/operation/update/op_msg_spec.rb +36 -21
- data/spec/mongo/operation/update_spec.rb +8 -6
- data/spec/mongo/operation/update_user_spec.rb +6 -6
- data/spec/mongo/protocol/compressed_spec.rb +3 -2
- data/spec/mongo/protocol/delete_spec.rb +1 -1
- data/spec/mongo/protocol/get_more_spec.rb +1 -1
- data/spec/mongo/protocol/insert_spec.rb +1 -1
- data/spec/mongo/protocol/kill_cursors_spec.rb +1 -1
- data/spec/mongo/protocol/msg_spec.rb +14 -13
- data/spec/mongo/protocol/query_spec.rb +1 -1
- data/spec/mongo/protocol/update_spec.rb +1 -1
- data/spec/mongo/retryable_spec.rb +84 -0
- data/spec/mongo/{cluster → server}/app_metadata_spec.rb +15 -3
- data/spec/mongo/server/connection_auth_spec.rb +114 -0
- data/spec/mongo/server/connection_pool/queue_spec.rb +146 -30
- data/spec/mongo/server/connection_pool_spec.rb +11 -12
- data/spec/mongo/server/connection_spec.rb +339 -152
- data/spec/mongo/server/description_query_methods_spec.rb +288 -0
- data/spec/mongo/server/description_spec.rb +63 -240
- data/spec/mongo/server/monitor/app_metadata_spec.rb +16 -0
- data/spec/mongo/server/monitor/connection_spec.rb +31 -28
- data/spec/mongo/server/monitor_spec.rb +61 -32
- data/spec/mongo/server/round_trip_time_averager_spec.rb +43 -0
- data/spec/mongo/server_selector_spec.rb +106 -1
- data/spec/mongo/server_spec.rb +31 -12
- data/spec/mongo/session/session_pool_spec.rb +3 -1
- data/spec/mongo/session_spec.rb +64 -2
- data/spec/mongo/session_transaction_spec.rb +64 -0
- data/spec/mongo/socket/ssl_spec.rb +86 -10
- data/spec/mongo/uri/srv_protocol_spec.rb +40 -40
- data/spec/mongo/uri_spec.rb +74 -38
- data/spec/spec_helper.rb +39 -64
- data/spec/spec_tests/connection_string_spec.rb +4 -32
- data/spec/spec_tests/crud_spec.rb +12 -2
- data/spec/{support/change_streams_tests → spec_tests/data/change_streams}/change-streams-errors.yml +0 -0
- data/spec/{support/change_streams_tests → spec_tests/data/change_streams}/change-streams.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/bulkWrite.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/command.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/deleteMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/deleteOne.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/find.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/insertMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/insertOne.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/unacknowledgedBulkWrite.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/updateMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/updateOne.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/invalid-uris.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-auth.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-db-with-dotted-name.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-host_identifiers.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-options.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-unix_socket-absolute.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-unix_socket-relative.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-warnings.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/aggregate-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/aggregate-out.yml +6 -6
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/aggregate.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/count-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/count.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/distinct-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/distinct.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/find-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/find.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/bulkWrite-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteMany-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteMany.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteOne-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteOne.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndDelete-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndDelete.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace-upsert.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace-upsert_pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndUpdate-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndUpdate-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndUpdate.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/insertMany.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/insertOne.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne-pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne-upsert.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany-pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne-pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/longer-parent-in-return.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/misformatted-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/no-results.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/not-enough-parts.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/one-result-default-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/one-txt-record-multiple-strings.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/one-txt-record.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch1.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch2.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch3.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch4.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch5.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/returned-parent-too-short.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/returned-parent-wrong.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/two-results-default-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/two-results-nonstandard-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/two-txt-records.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-not-allowed-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-with-overridden-ssl-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-with-overridden-uri-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-with-unallowed-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/uri-with-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/uri-with-two-hosts.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/delete.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/download.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/download_by_name.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/upload.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Nearest.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Secondary.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Nearest.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Sharded/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Sharded/SmallMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Single/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Single/SmallMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Unknown/SmallMaxStaleness.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/bulkWrite-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/bulkWrite.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/deleteOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/deleteOne.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndDelete-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndDelete.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndReplace-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndReplace.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndUpdate-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndUpdate.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertMany-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertMany.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertOne.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/replaceOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/replaceOne.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/updateOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/updateOne.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/compatible.yml +0 -0
- data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +31 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_arbiters.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_passives.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_primary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_secondary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discovery.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/equal_electionids.yml +2 -0
- data/spec/{support → spec_tests/data}/sdam/rs/ghost_discovered.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/hosts_differ_from_seeds.yml +0 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +32 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +32 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +32 -0
- data/spec/{support → spec_tests/data}/sdam/rs/ls_timeout.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/member_reconfig.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/member_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary_new_electionid.yml +6 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary_new_setversion.yml +6 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary_wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/non_rs_member.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/normalize_case.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/normalize_case_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/null_election_id.yml +7 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +63 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +56 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_becomes_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_changes_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_disconnect.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_disconnect_electionid.yml +10 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_disconnect_setversion.yml +10 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_reports_new_member.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_to_no_primary_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/response_from_removed.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/rsother_discovered.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/sec_not_auth.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_ignore_ok_0.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_wrong_set_name_with_primary.yml +0 -0
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary_second.yml +73 -0
- data/spec/{support → spec_tests/data}/sdam/rs/setversion_without_electionid.yml +2 -0
- data/spec/{support → spec_tests/data}/sdam/rs/stepdown_change_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/too_new.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/too_old.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/unexpected_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/use_setversion_without_electionid.yml +6 -0
- data/spec/{support → spec_tests/data}/sdam/rs/wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/compatible.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/ls_timeout_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/mongos_disconnect.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/multiple_mongoses.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/non_mongos_removed.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/normalize_uri_case.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/single_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/too_new.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/too_old.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/compatible.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_external_ip.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_rsarbiter.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_rsprimary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_rssecondary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_slave.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/ls_timeout_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/not_ok_response.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/standalone_removed.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/too_new.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/too_old.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/unavailable_seed.yml +0 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +72 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_chain.yml +222 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_change.yml +225 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_seed.yml +233 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/replica_set_with_no_primary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/replica_set_with_primary.yml +0 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_and_secondary.yml +198 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_removal.yml +171 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/replica_set_with_removal.yml +0 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_second_seed_removal.yml +106 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/required_replica_set.yml +23 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/standalone.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +86 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Nearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Nearest_multiple.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PossiblePrimary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Primary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Nearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Nearest_multiple.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Primary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Secondary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/Nearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/Primary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/PrimaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/Secondary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Single/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Unknown/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/first_value.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/first_value_zero.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_1.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_2.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_3.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_4.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_5.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/abort.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/bulk.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/causal-consistency.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/commit.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/delete.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/error-labels.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/errors.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/findOneAndDelete.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/findOneAndReplace.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/findOneAndUpdate.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/insert.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/isolation.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/read-pref.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/reads.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/retryable-abort.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/retryable-commit.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/retryable-writes.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/run-command.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/transaction-options.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/update.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/write-concern.yml +0 -0
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +156 -0
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +192 -0
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +203 -0
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +261 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +132 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +178 -0
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +269 -0
- data/spec/spec_tests/data/transactions_api/commit.yml +181 -0
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +258 -0
- data/spec/spec_tests/data/uri_options/auth-options.yml +14 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +48 -0
- data/spec/spec_tests/data/uri_options/concern-options.yml +55 -0
- data/spec/spec_tests/data/uri_options/connection-options.yml +106 -0
- data/spec/spec_tests/data/uri_options/connection-pool-options.yml +26 -0
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +42 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +89 -0
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +0 -40
- data/spec/spec_tests/gridfs_spec.rb +1 -1
- data/spec/spec_tests/max_staleness_spec.rb +21 -8
- data/spec/spec_tests/retryable_writes_spec.rb +6 -6
- data/spec/spec_tests/sdam_monitoring_spec.rb +38 -20
- data/spec/spec_tests/sdam_spec.rb +80 -15
- data/spec/spec_tests/server_selection_rtt_spec.rb +6 -63
- data/spec/spec_tests/server_selection_spec.rb +18 -3
- data/spec/spec_tests/transactions_api_spec.rb +60 -0
- data/spec/spec_tests/transactions_spec.rb +20 -13
- data/spec/spec_tests/uri_options_spec.rb +94 -0
- data/spec/support/authorization.rb +28 -167
- data/spec/support/change_streams.rb +7 -7
- data/spec/support/change_streams/operation.rb +1 -1
- data/spec/support/client_registry.rb +170 -0
- data/spec/support/client_registry_macros.rb +14 -0
- data/spec/support/cluster_config.rb +49 -0
- data/spec/support/command_monitoring.rb +3 -3
- data/spec/support/common_shortcuts.rb +12 -0
- data/spec/support/connection_string.rb +99 -7
- data/spec/support/constraints.rb +24 -13
- data/spec/support/crud.rb +9 -97
- data/spec/support/crud/read.rb +2 -2
- data/spec/support/crud/verifier.rb +98 -0
- data/spec/support/crud/write.rb +2 -2
- data/spec/support/event_subscriber.rb +25 -13
- data/spec/support/gridfs.rb +8 -5
- data/spec/support/json_ext_formatter.rb +9 -0
- data/spec/support/lite_constraints.rb +27 -1
- data/spec/support/monitoring_ext.rb +16 -0
- data/spec/support/sdam_formatter_integration.rb +110 -0
- data/spec/support/sdam_monitoring.rb +77 -17
- data/spec/support/server_discovery_and_monitoring.rb +43 -20
- data/spec/support/server_selection.rb +3 -13
- data/spec/support/server_selection_rtt.rb +10 -10
- data/spec/support/shared/server_selector.rb +13 -41
- data/spec/support/shared/session.rb +44 -22
- data/spec/support/spec_config.rb +186 -11
- data/spec/support/spec_setup.rb +61 -0
- data/spec/support/transactions.rb +79 -145
- data/spec/support/transactions/operation.rb +53 -14
- data/spec/support/transactions/verifier.rb +94 -0
- metadata +712 -565
- metadata.gz.sig +0 -0
- data/lib/mongo/cluster/topology/replica_set.rb +0 -339
- data/lib/mongo/event/member_discovered.rb +0 -67
- data/lib/mongo/event/primary_elected.rb +0 -55
- data/lib/mongo/event/standalone_discovered.rb +0 -53
- data/lib/mongo/server/description/inspector.rb +0 -81
- data/lib/mongo/server/description/inspector/description_changed.rb +0 -57
- data/lib/mongo/server/description/inspector/member_discovered.rb +0 -59
- data/lib/mongo/server/description/inspector/primary_elected.rb +0 -60
- data/lib/mongo/server/description/inspector/standalone_discovered.rb +0 -56
- data/spec/mongo/server/description/inspector/description_changed_spec.rb +0 -78
- data/spec/mongo/server/description/inspector/primary_elected_spec.rb +0 -94
- data/spec/support/sdam/rs/set_version_without_electionid.yml +0 -69
- data/spec/support/travis.rb +0 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2019 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -24,6 +24,28 @@ module Mongo
|
|
24
24
|
include Loggable
|
25
25
|
extend Forwardable
|
26
26
|
|
27
|
+
# Create the new connection pool.
|
28
|
+
#
|
29
|
+
# @example Create the new connection pool.
|
30
|
+
# Pool.new(wait_queue_timeout: 0.5) do
|
31
|
+
# Connection.new
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# @note A block must be passed to set up the connections on initialization.
|
35
|
+
#
|
36
|
+
# @param [ Hash ] options The connection pool options.
|
37
|
+
#
|
38
|
+
# @option options [ Integer ] :max_pool_size The maximum pool size.
|
39
|
+
# @option options [ Integer ] :min_pool_size The minimum pool size.
|
40
|
+
# @option options [ Float ] :wait_queue_timeout The time to wait, in
|
41
|
+
# seconds, for a free connection.
|
42
|
+
#
|
43
|
+
# @since 2.0.0
|
44
|
+
def initialize(options = {}, &block)
|
45
|
+
@options = options.freeze
|
46
|
+
@queue = Queue.new(options, &block)
|
47
|
+
end
|
48
|
+
|
27
49
|
# @return [ Hash ] options The pool options.
|
28
50
|
attr_reader :options
|
29
51
|
|
@@ -66,23 +88,6 @@ module Mongo
|
|
66
88
|
queue.disconnect!
|
67
89
|
end
|
68
90
|
|
69
|
-
# Create the new connection pool.
|
70
|
-
#
|
71
|
-
# @example Create the new connection pool.
|
72
|
-
# Pool.new(timeout: 0.5) do
|
73
|
-
# Connection.new
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# @note A block must be passed to set up the connections on initialization.
|
77
|
-
#
|
78
|
-
# @param [ Hash ] options The connection pool options.
|
79
|
-
#
|
80
|
-
# @since 2.0.0
|
81
|
-
def initialize(options = {}, &block)
|
82
|
-
@options = options.freeze
|
83
|
-
@queue = Queue.new(options, &block)
|
84
|
-
end
|
85
|
-
|
86
91
|
# Get a pretty printed string inspection for the pool.
|
87
92
|
#
|
88
93
|
# @example Inspect the pool.
|
@@ -131,8 +136,8 @@ module Mongo
|
|
131
136
|
#
|
132
137
|
# @since 2.0.0
|
133
138
|
def get(server)
|
134
|
-
ConnectionPool.new(server.options) do
|
135
|
-
Connection.new(server, server.options)
|
139
|
+
ConnectionPool.new(server.options) do |generation|
|
140
|
+
Connection.new(server, server.options.merge(generation: generation))
|
136
141
|
end
|
137
142
|
end
|
138
143
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2019 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -19,22 +19,76 @@ module Mongo
|
|
19
19
|
# A LIFO queue of connections to be used by the connection pool. This is
|
20
20
|
# based on mperham's connection pool.
|
21
21
|
#
|
22
|
+
# @note The queue contains active connections that are available for
|
23
|
+
# use. It does not track connections which are in use (checked out).
|
24
|
+
# It is easy to confuse the size of the connection pool (number of
|
25
|
+
# connections that are used plus number of connections that are
|
26
|
+
# available for use) and the size of the queue (number of connections
|
27
|
+
# that have already been created that are available for use).
|
28
|
+
# API documentation for this class states whether each size refers
|
29
|
+
# to the pool or to the queue size. Note that minimum and maximum
|
30
|
+
# sizes only make sense when talking about the connection pool,
|
31
|
+
# as the size of the queue of available connections is determined by
|
32
|
+
# the size constraints of the pool plus how many connections are
|
33
|
+
# currently checked out.
|
34
|
+
#
|
22
35
|
# @since 2.0.0
|
23
36
|
class Queue
|
37
|
+
include Loggable
|
24
38
|
extend Forwardable
|
25
39
|
|
26
|
-
#
|
27
|
-
def_delegators :queue, :size
|
28
|
-
|
29
|
-
# The default max size for the queue.
|
40
|
+
# The default max size for the connection pool.
|
30
41
|
MAX_SIZE = 5.freeze
|
31
42
|
|
32
|
-
# The default min size for the
|
43
|
+
# The default min size for the connection pool.
|
33
44
|
MIN_SIZE = 1.freeze
|
34
45
|
|
35
46
|
# The default timeout, in seconds, to wait for a connection.
|
36
47
|
WAIT_TIMEOUT = 1.freeze
|
37
48
|
|
49
|
+
# Initialize the new queue. Will yield the block the number of times
|
50
|
+
# equal to the initial connection pool size.
|
51
|
+
#
|
52
|
+
# @example Create the queue.
|
53
|
+
# Mongo::Server::ConnectionPool::Queue.new(max_pool_size: 5) { Connection.new }
|
54
|
+
#
|
55
|
+
# @param [ Hash ] options The options.
|
56
|
+
#
|
57
|
+
# @option options [ Integer ] :max_pool_size The maximum pool size.
|
58
|
+
# @option options [ Integer ] :min_pool_size The minimum pool size.
|
59
|
+
# @option options [ Float ] :wait_queue_timeout The time to wait, in
|
60
|
+
# seconds, for a free connection.
|
61
|
+
#
|
62
|
+
# @since 2.0.0
|
63
|
+
def initialize(options = {}, &block)
|
64
|
+
if options[:min_pool_size] && options[:max_pool_size] &&
|
65
|
+
options[:min_pool_size] > options[:max_pool_size]
|
66
|
+
then
|
67
|
+
raise ArgumentError, "Cannot have min size > max size"
|
68
|
+
end
|
69
|
+
@block = block
|
70
|
+
# This is the number of connections in the pool.
|
71
|
+
# Includes available connections in the queue and the checked
|
72
|
+
# out connections that we don't otherwise track.
|
73
|
+
@pool_size = 0
|
74
|
+
@options = options
|
75
|
+
@generation = 1
|
76
|
+
if min_size > max_size
|
77
|
+
raise ArgumentError, "min_size (#{min_size}) cannot exceed max_size (#{max_size})"
|
78
|
+
end
|
79
|
+
@queue = Array.new(min_size) { create_connection }
|
80
|
+
@mutex = Mutex.new
|
81
|
+
@resource = ConditionVariable.new
|
82
|
+
check_count_invariants
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [ Integer ] generation Generation of connections currently
|
86
|
+
# being used by the queue.
|
87
|
+
#
|
88
|
+
# @since 2.7.0
|
89
|
+
# @api private
|
90
|
+
attr_reader :generation
|
91
|
+
|
38
92
|
# @return [ Array ] queue The underlying array of connections.
|
39
93
|
attr_reader :queue
|
40
94
|
|
@@ -47,19 +101,43 @@ module Mongo
|
|
47
101
|
# @return [ ConditionVariable ] resource The resource.
|
48
102
|
attr_reader :resource
|
49
103
|
|
50
|
-
#
|
51
|
-
#
|
104
|
+
# Number of connections that the pool has which are ready to be
|
105
|
+
# checked out. This is NOT the size of the connection pool (total
|
106
|
+
# number of active connections created by the pool).
|
107
|
+
def_delegators :queue, :size
|
108
|
+
|
109
|
+
# Number of connections that the pool has which are ready to be
|
110
|
+
# checked out.
|
111
|
+
#
|
112
|
+
# @since 2.7.0
|
113
|
+
alias_method :queue_size, :size
|
114
|
+
|
115
|
+
# Number of connections in the pool (active connections ready to
|
116
|
+
# be checked out plus connections already checked out).
|
117
|
+
#
|
118
|
+
# @since 2.7.0
|
119
|
+
attr_reader :pool_size
|
120
|
+
|
121
|
+
# Retrieves a connection. If there are active connections in the
|
122
|
+
# queue, the most recently used connection is returned. Otherwise
|
123
|
+
# if the connection pool size is less than the max size, creates a
|
124
|
+
# new connection and returns it. Otherwise raises Timeout::Error.
|
52
125
|
#
|
53
126
|
# @example Dequeue a connection.
|
54
127
|
# queue.dequeue
|
55
128
|
#
|
56
129
|
# @return [ Mongo::Server::Connection ] The next connection.
|
130
|
+
# @raise [ Timeout::Error ] If the connection pool is at maximum size
|
131
|
+
# and remains so for longer than the wait timeout.
|
57
132
|
#
|
58
133
|
# @since 2.0.0
|
59
134
|
def dequeue
|
135
|
+
check_count_invariants
|
60
136
|
mutex.synchronize do
|
61
137
|
dequeue_connection
|
62
138
|
end
|
139
|
+
ensure
|
140
|
+
check_count_invariants
|
63
141
|
end
|
64
142
|
|
65
143
|
# Disconnect all connections in the queue.
|
@@ -71,14 +149,40 @@ module Mongo
|
|
71
149
|
#
|
72
150
|
# @since 2.1.0
|
73
151
|
def disconnect!
|
152
|
+
check_count_invariants
|
74
153
|
mutex.synchronize do
|
75
154
|
queue.each{ |connection| connection.disconnect! }
|
155
|
+
@pool_size -= queue.length
|
156
|
+
if @pool_size < 0
|
157
|
+
# This should never happen
|
158
|
+
log_warn("ConnectionPool::Queue: connection accounting problem")
|
159
|
+
@pool_size = 0
|
160
|
+
end
|
161
|
+
queue.clear
|
162
|
+
@generation += 1
|
163
|
+
while @pool_size < min_size
|
164
|
+
@pool_size += 1
|
165
|
+
queue.unshift(@block.call(@generation))
|
166
|
+
end
|
76
167
|
true
|
77
168
|
end
|
169
|
+
ensure
|
170
|
+
check_count_invariants
|
78
171
|
end
|
79
172
|
|
80
173
|
# Enqueue a connection in the queue.
|
81
174
|
#
|
175
|
+
# Only connections created by this queue should be enqueued
|
176
|
+
# back into it, however the queue does not verify whether it
|
177
|
+
# originally created the connection being enqueued.
|
178
|
+
#
|
179
|
+
# If linting is enabled (see Mongo::Lint), attempting to enqueue
|
180
|
+
# connections beyond the pool's capacity will raise Mongo::Error::LintError
|
181
|
+
# (since some of those connections must not have originated from
|
182
|
+
# the queue into which they are being enqueued). If linting is
|
183
|
+
# not enabled, the queue can grow beyond its max size with undefined
|
184
|
+
# results.
|
185
|
+
#
|
82
186
|
# @example Enqueue a connection.
|
83
187
|
# queue.enqueue(connection)
|
84
188
|
#
|
@@ -86,33 +190,31 @@ module Mongo
|
|
86
190
|
#
|
87
191
|
# @since 2.0.0
|
88
192
|
def enqueue(connection)
|
193
|
+
check_count_invariants
|
89
194
|
mutex.synchronize do
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
195
|
+
if connection.generation == @generation
|
196
|
+
queue.unshift(connection.record_checkin!)
|
197
|
+
resource.broadcast
|
198
|
+
else
|
199
|
+
connection.disconnect!
|
94
200
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
@options = options
|
113
|
-
@queue = Array.new(min_size) { create_connection }
|
114
|
-
@mutex = Mutex.new
|
115
|
-
@resource = ConditionVariable.new
|
201
|
+
@pool_size = if @pool_size > 0
|
202
|
+
@pool_size - 1
|
203
|
+
else
|
204
|
+
# This should never happen
|
205
|
+
log_warn("ConnectionPool::Queue: unexpected enqueue")
|
206
|
+
0
|
207
|
+
end
|
208
|
+
|
209
|
+
while @pool_size < min_size
|
210
|
+
@pool_size += 1
|
211
|
+
queue.unshift(@block.call(@generation))
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
nil
|
216
|
+
ensure
|
217
|
+
check_count_invariants
|
116
218
|
end
|
117
219
|
|
118
220
|
# Get a pretty printed string inspection for the queue.
|
@@ -125,27 +227,27 @@ module Mongo
|
|
125
227
|
# @since 2.0.0
|
126
228
|
def inspect
|
127
229
|
"#<Mongo::Server::ConnectionPool::Queue:0x#{object_id} min_size=#{min_size} max_size=#{max_size} " +
|
128
|
-
"wait_timeout=#{wait_timeout} current_size=#{
|
230
|
+
"wait_timeout=#{wait_timeout} current_size=#{queue_size}>"
|
129
231
|
end
|
130
232
|
|
131
|
-
# Get the maximum size of the
|
233
|
+
# Get the maximum size of the connection pool.
|
132
234
|
#
|
133
235
|
# @example Get the max size.
|
134
236
|
# queue.max_size
|
135
237
|
#
|
136
|
-
# @return [ Integer ] The maximum size of the
|
238
|
+
# @return [ Integer ] The maximum size of the connection pool.
|
137
239
|
#
|
138
240
|
# @since 2.0.0
|
139
241
|
def max_size
|
140
|
-
@max_size ||= options[:max_pool_size] || MAX_SIZE
|
242
|
+
@max_size ||= options[:max_pool_size] || [MAX_SIZE, min_size].max
|
141
243
|
end
|
142
244
|
|
143
|
-
# Get the minimum size of the
|
245
|
+
# Get the minimum size of the connection pool.
|
144
246
|
#
|
145
247
|
# @example Get the min size.
|
146
248
|
# queue.min_size
|
147
249
|
#
|
148
|
-
# @return [ Integer ] The minimum size of the
|
250
|
+
# @return [ Integer ] The minimum size of the connection pool.
|
149
251
|
#
|
150
252
|
# @since 2.0.0
|
151
253
|
def min_size
|
@@ -164,7 +266,8 @@ module Mongo
|
|
164
266
|
@wait_timeout ||= options[:wait_queue_timeout] || WAIT_TIMEOUT
|
165
267
|
end
|
166
268
|
|
167
|
-
# The maximum seconds a socket can remain idle since it has been
|
269
|
+
# The maximum seconds a socket can remain idle since it has been
|
270
|
+
# checked in to the pool.
|
168
271
|
#
|
169
272
|
# @example Get the max idle time.
|
170
273
|
# queue.max_idle_time
|
@@ -176,14 +279,15 @@ module Mongo
|
|
176
279
|
@max_idle_time ||= options[:max_idle_time]
|
177
280
|
end
|
178
281
|
|
179
|
-
# Close sockets that have been open for longer than the max idle time,
|
180
|
-
# option is set.
|
282
|
+
# Close sockets that have been open for longer than the max idle time,
|
283
|
+
# if the option is set.
|
181
284
|
#
|
182
285
|
# @example Close the stale sockets
|
183
286
|
# queue.close_stale_sockets!
|
184
287
|
#
|
185
288
|
# @since 2.5.0
|
186
289
|
def close_stale_sockets!
|
290
|
+
check_count_invariants
|
187
291
|
return unless max_idle_time
|
188
292
|
|
189
293
|
to_refresh = []
|
@@ -196,7 +300,7 @@ module Mongo
|
|
196
300
|
end
|
197
301
|
|
198
302
|
mutex.synchronize do
|
199
|
-
num_checked_out =
|
303
|
+
num_checked_out = pool_size - queue_size
|
200
304
|
min_size_delta = [(min_size - num_checked_out), 0].max
|
201
305
|
|
202
306
|
to_refresh.each do |connection|
|
@@ -208,6 +312,8 @@ module Mongo
|
|
208
312
|
end
|
209
313
|
end
|
210
314
|
end
|
315
|
+
ensure
|
316
|
+
check_count_invariants
|
211
317
|
end
|
212
318
|
|
213
319
|
private
|
@@ -223,9 +329,9 @@ module Mongo
|
|
223
329
|
end
|
224
330
|
|
225
331
|
def create_connection
|
226
|
-
if
|
227
|
-
@
|
228
|
-
@block.call
|
332
|
+
if pool_size < max_size
|
333
|
+
@pool_size += 1
|
334
|
+
@block.call(@generation)
|
229
335
|
end
|
230
336
|
end
|
231
337
|
|
@@ -236,6 +342,17 @@ module Mongo
|
|
236
342
|
end
|
237
343
|
resource.wait(mutex, wait)
|
238
344
|
end
|
345
|
+
|
346
|
+
def check_count_invariants
|
347
|
+
if Mongo::Lint.enabled?
|
348
|
+
if pool_size < min_size
|
349
|
+
raise Error::LintError, 'connection pool queue: underflow'
|
350
|
+
end
|
351
|
+
if pool_size > max_size
|
352
|
+
raise Error::LintError, 'connection pool queue: overflow'
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
239
356
|
end
|
240
357
|
end
|
241
358
|
end
|
data/lib/mongo/server/context.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2019 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -24,6 +24,18 @@ module Mongo
|
|
24
24
|
class Context
|
25
25
|
extend Forwardable
|
26
26
|
|
27
|
+
# Instantiate a server context.
|
28
|
+
#
|
29
|
+
# @example Instantiate a server context.
|
30
|
+
# Mongo::Server::Context.new(server)
|
31
|
+
#
|
32
|
+
# @param [ Mongo::Server ] server The server the context is for.
|
33
|
+
#
|
34
|
+
# @since 2.0.0
|
35
|
+
def initialize(server)
|
36
|
+
@server = server
|
37
|
+
end
|
38
|
+
|
27
39
|
# @return [ Mongo::Server ] server The server the context is for.
|
28
40
|
attr_reader :server
|
29
41
|
|
@@ -38,18 +50,6 @@ module Mongo
|
|
38
50
|
:secondary?,
|
39
51
|
:standalone?
|
40
52
|
|
41
|
-
# Instantiate a server context.
|
42
|
-
#
|
43
|
-
# @example Instantiate a server context.
|
44
|
-
# Mongo::Server::Context.new(server)
|
45
|
-
#
|
46
|
-
# @param [ Mongo::Server ] server The server the context is for.
|
47
|
-
#
|
48
|
-
# @since 2.0.0
|
49
|
-
def initialize(server)
|
50
|
-
@server = server
|
51
|
-
end
|
52
|
-
|
53
53
|
# Execute a block of code with a connection, that is checked out of the
|
54
54
|
# pool and then checked back in.
|
55
55
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2019 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -13,7 +13,6 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'mongo/server/description/features'
|
16
|
-
require 'mongo/server/description/inspector'
|
17
16
|
|
18
17
|
module Mongo
|
19
18
|
class Server
|
@@ -107,6 +106,7 @@ module Mongo
|
|
107
106
|
# The legacy wire protocol version.
|
108
107
|
#
|
109
108
|
# @since 2.0.0
|
109
|
+
# @deprecated Will be removed in 3.0.
|
110
110
|
LEGACY_WIRE_VERSION = 0.freeze
|
111
111
|
|
112
112
|
# Constant for reading passive info from config.
|
@@ -177,6 +177,37 @@ module Mongo
|
|
177
177
|
OPERATION_TIME,
|
178
178
|
Operation::CLUSTER_TIME ].freeze
|
179
179
|
|
180
|
+
# Instantiate the new server description from the result of the ismaster
|
181
|
+
# command.
|
182
|
+
#
|
183
|
+
# @example Instantiate the new description.
|
184
|
+
# Description.new(address, { 'ismaster' => true }, 0.5)
|
185
|
+
#
|
186
|
+
# @param [ Address ] address The server address.
|
187
|
+
# @param [ Hash ] config The result of the ismaster command.
|
188
|
+
# @param [ Float ] average_round_trip_time The moving average time (sec) the ismaster
|
189
|
+
# call took to complete.
|
190
|
+
#
|
191
|
+
# @since 2.0.0
|
192
|
+
def initialize(address, config = {}, average_round_trip_time = nil)
|
193
|
+
@address = address
|
194
|
+
@config = config
|
195
|
+
unless unknown?
|
196
|
+
@features = Features.new(wire_versions, me || @address.to_s)
|
197
|
+
end
|
198
|
+
@average_round_trip_time = average_round_trip_time
|
199
|
+
@last_update_time = Time.now.freeze
|
200
|
+
|
201
|
+
if Mongo::Lint.enabled?
|
202
|
+
# prepopulate cache instance variables
|
203
|
+
hosts
|
204
|
+
arbiters
|
205
|
+
passives
|
206
|
+
|
207
|
+
freeze
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
180
211
|
# @return [ Address ] address The server's address.
|
181
212
|
attr_reader :address
|
182
213
|
|
@@ -184,7 +215,12 @@ module Mongo
|
|
184
215
|
attr_reader :config
|
185
216
|
|
186
217
|
# @return [ Features ] features The features for the server.
|
187
|
-
|
218
|
+
def features
|
219
|
+
if unknown?
|
220
|
+
raise ArgumentError, "An unknown server's features are not known"
|
221
|
+
end
|
222
|
+
@features
|
223
|
+
end
|
188
224
|
|
189
225
|
# @return [ Float ] The moving average time the ismaster call took to complete.
|
190
226
|
attr_reader :average_round_trip_time
|
@@ -198,7 +234,7 @@ module Mongo
|
|
198
234
|
#
|
199
235
|
# @since 2.0.0
|
200
236
|
def arbiter?
|
201
|
-
!!config[ARBITER] && !replica_set_name.nil?
|
237
|
+
ok? && !!config[ARBITER] && !replica_set_name.nil?
|
202
238
|
end
|
203
239
|
|
204
240
|
# Get a list of all arbiters in the replica set.
|
@@ -222,7 +258,7 @@ module Mongo
|
|
222
258
|
#
|
223
259
|
# @since 2.0.0
|
224
260
|
def ghost?
|
225
|
-
!!config[REPLICA_SET]
|
261
|
+
ok? && !!config[REPLICA_SET]
|
226
262
|
end
|
227
263
|
|
228
264
|
# Will return true if the server is hidden.
|
@@ -234,7 +270,7 @@ module Mongo
|
|
234
270
|
#
|
235
271
|
# @since 2.0.0
|
236
272
|
def hidden?
|
237
|
-
!!config[HIDDEN]
|
273
|
+
ok? && !!config[HIDDEN]
|
238
274
|
end
|
239
275
|
|
240
276
|
# Get a list of all servers in the replica set.
|
@@ -249,25 +285,6 @@ module Mongo
|
|
249
285
|
@hosts ||= (config[HOSTS] || []).map { |s| s.downcase }
|
250
286
|
end
|
251
287
|
|
252
|
-
# Instantiate the new server description from the result of the ismaster
|
253
|
-
# command.
|
254
|
-
#
|
255
|
-
# @example Instantiate the new description.
|
256
|
-
# Description.new(address, { 'ismaster' => true }, 0.5)
|
257
|
-
#
|
258
|
-
# @param [ Address ] address The server address.
|
259
|
-
# @param [ Hash ] config The result of the ismaster command.
|
260
|
-
# @param [ Float ] average_round_trip_time The moving average time (sec) the ismaster
|
261
|
-
# call took to complete.
|
262
|
-
#
|
263
|
-
# @since 2.0.0
|
264
|
-
def initialize(address, config = {}, average_round_trip_time = 0)
|
265
|
-
@address = address
|
266
|
-
@config = config
|
267
|
-
@features = Features.new(wire_versions, me || @address.to_s)
|
268
|
-
@average_round_trip_time = average_round_trip_time
|
269
|
-
end
|
270
|
-
|
271
288
|
# Inspect the server description.
|
272
289
|
#
|
273
290
|
# @example Inspect the server description
|
@@ -325,7 +342,7 @@ module Mongo
|
|
325
342
|
#
|
326
343
|
# @since 2.0.0
|
327
344
|
def max_wire_version
|
328
|
-
config[MAX_WIRE_VERSION]
|
345
|
+
config[MAX_WIRE_VERSION]
|
329
346
|
end
|
330
347
|
|
331
348
|
# Get the minimum wire version.
|
@@ -337,7 +354,7 @@ module Mongo
|
|
337
354
|
#
|
338
355
|
# @since 2.0.0
|
339
356
|
def min_wire_version
|
340
|
-
config[MIN_WIRE_VERSION]
|
357
|
+
config[MIN_WIRE_VERSION]
|
341
358
|
end
|
342
359
|
|
343
360
|
# Get the me field value.
|
@@ -421,7 +438,7 @@ module Mongo
|
|
421
438
|
#
|
422
439
|
# @since 2.0.0
|
423
440
|
def mongos?
|
424
|
-
config[MESSAGE] == MONGOS_MESSAGE
|
441
|
+
ok? && config[MESSAGE] == MONGOS_MESSAGE
|
425
442
|
end
|
426
443
|
|
427
444
|
# Is the description of type other.
|
@@ -433,6 +450,12 @@ module Mongo
|
|
433
450
|
#
|
434
451
|
# @since 2.0.0
|
435
452
|
def other?
|
453
|
+
# The SDAM spec is slightly confusing on what "other" means,
|
454
|
+
# but it's referred to it as "RSOther" which means a non-RS member
|
455
|
+
# cannot be "other".
|
456
|
+
if unknown? || replica_set_name.nil?
|
457
|
+
return false
|
458
|
+
end
|
436
459
|
(!primary? && !secondary? && !passive? && !arbiter?) ||
|
437
460
|
(hidden? && !replica_set_name.nil?)
|
438
461
|
end
|
@@ -446,7 +469,7 @@ module Mongo
|
|
446
469
|
#
|
447
470
|
# @since 2.0.0
|
448
471
|
def passive?
|
449
|
-
!!config[PASSIVE]
|
472
|
+
ok? && !!config[PASSIVE]
|
450
473
|
end
|
451
474
|
|
452
475
|
# Get a list of the passive servers in the cluster.
|
@@ -482,9 +505,10 @@ module Mongo
|
|
482
505
|
#
|
483
506
|
# @since 2.0.0
|
484
507
|
def primary?
|
485
|
-
|
508
|
+
ok? &&
|
509
|
+
!!config[PRIMARY] &&
|
486
510
|
(primary_host.nil? || primary_host == address.to_s) &&
|
487
|
-
|
511
|
+
!replica_set_name.nil?
|
488
512
|
end
|
489
513
|
|
490
514
|
# Get the name of the replica set the server belongs to, returns nil if
|
@@ -521,7 +545,7 @@ module Mongo
|
|
521
545
|
#
|
522
546
|
# @since 2.0.0
|
523
547
|
def secondary?
|
524
|
-
!!config[SECONDARY] && !replica_set_name.nil?
|
548
|
+
ok? && !!config[SECONDARY] && !replica_set_name.nil?
|
525
549
|
end
|
526
550
|
|
527
551
|
# Returns the server type as a symbol.
|
@@ -539,6 +563,7 @@ module Mongo
|
|
539
563
|
return :primary if primary?
|
540
564
|
return :secondary if secondary?
|
541
565
|
return :standalone if standalone?
|
566
|
+
return :other if other?
|
542
567
|
:unknown
|
543
568
|
end
|
544
569
|
|
@@ -563,22 +588,13 @@ module Mongo
|
|
563
588
|
#
|
564
589
|
# @since 2.0.0
|
565
590
|
def unknown?
|
566
|
-
config.empty? ||
|
567
|
-
config[Operation::Result::OK] != 1)
|
591
|
+
config.empty? || !ok?
|
568
592
|
end
|
569
593
|
|
570
|
-
#
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
# @example Force an unknown state.
|
575
|
-
# description.unknown!
|
576
|
-
#
|
577
|
-
# @return [ true ] Always true.
|
578
|
-
#
|
579
|
-
# @since 2.0.0
|
580
|
-
def unknown!
|
581
|
-
@config = {} and true
|
594
|
+
# @api private
|
595
|
+
def ok?
|
596
|
+
config[Operation::Result::OK] &&
|
597
|
+
config[Operation::Result::OK] == 1 || false
|
582
598
|
end
|
583
599
|
|
584
600
|
# Get the range of supported wire versions for the server.
|
@@ -628,7 +644,18 @@ module Mongo
|
|
628
644
|
#
|
629
645
|
# @since 2.0.6
|
630
646
|
def replica_set_member?
|
631
|
-
!(standalone? || mongos?)
|
647
|
+
ok? && !(standalone? || mongos?)
|
648
|
+
end
|
649
|
+
|
650
|
+
# Whether this description is from a data-bearing server
|
651
|
+
# (standalone, mongos, primary or secondary).
|
652
|
+
#
|
653
|
+
# @return [ true, false ] Whether the description is from a data-bearing
|
654
|
+
# server.
|
655
|
+
#
|
656
|
+
# @since 2.7.0
|
657
|
+
def data_bearing?
|
658
|
+
mongos? || primary? || secondary? || standalone?
|
632
659
|
end
|
633
660
|
|
634
661
|
# Check if there is a mismatch between the address host and the me field.
|
@@ -643,6 +670,24 @@ module Mongo
|
|
643
670
|
!!(address.to_s.downcase != me.downcase if me)
|
644
671
|
end
|
645
672
|
|
673
|
+
# opTime in lastWrite subdocument of the ismaster response.
|
674
|
+
#
|
675
|
+
# @return [ BSON::Timestamp ] The timestamp.
|
676
|
+
#
|
677
|
+
# @since 2.7.0
|
678
|
+
def op_time
|
679
|
+
if config['lastWrite'] && config['lastWrite']['opTime']
|
680
|
+
config['lastWrite']['opTime']['ts']
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
# Time when the server was last checked.
|
685
|
+
#
|
686
|
+
# @return [ Time ] Last check time.
|
687
|
+
#
|
688
|
+
# @since 2.7.0
|
689
|
+
attr_reader :last_update_time
|
690
|
+
|
646
691
|
# Check equality of two descriptions.
|
647
692
|
#
|
648
693
|
# @example Check description equality.
|
@@ -663,7 +708,7 @@ module Mongo
|
|
663
708
|
private
|
664
709
|
|
665
710
|
def compare_config(other)
|
666
|
-
config.keys.all? do |k|
|
711
|
+
(config.keys + other.config.keys).uniq.all? do |k|
|
667
712
|
config[k] == other.config[k] || EXCLUDE_FOR_COMPARISON.include?(k)
|
668
713
|
end
|
669
714
|
end
|