mongo 2.5.3 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/README.md +3 -2
- data/lib/mongo.rb +2 -2
- data/lib/mongo/address.rb +10 -2
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +26 -5
- data/lib/mongo/address/unix.rb +1 -1
- data/lib/mongo/auth.rb +10 -3
- data/lib/mongo/auth/cr.rb +4 -1
- data/lib/mongo/auth/cr/conversation.rb +4 -1
- data/lib/mongo/auth/ldap.rb +1 -1
- data/lib/mongo/auth/ldap/conversation.rb +1 -1
- data/lib/mongo/auth/roles.rb +1 -1
- data/lib/mongo/auth/scram.rb +24 -7
- data/lib/mongo/auth/scram/conversation.rb +52 -19
- data/lib/mongo/auth/stringprep.rb +114 -0
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +73 -0
- data/lib/mongo/auth/stringprep/tables.rb +3232 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +174 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1170 -0
- data/lib/mongo/auth/user.rb +14 -3
- data/lib/mongo/auth/user/view.rb +1 -1
- data/lib/mongo/auth/x509.rb +1 -1
- data/lib/mongo/auth/x509/conversation.rb +1 -1
- data/lib/mongo/bson.rb +1 -1
- data/lib/mongo/bulk_write.rb +8 -8
- data/lib/mongo/bulk_write/combineable.rb +1 -1
- 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 +4 -4
- data/lib/mongo/bulk_write/transformable.rb +1 -1
- data/lib/mongo/bulk_write/unordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/validatable.rb +1 -1
- data/lib/mongo/client.rb +115 -24
- data/lib/mongo/cluster.rb +17 -10
- data/lib/mongo/cluster/app_metadata.rb +7 -1
- data/lib/mongo/cluster/periodic_executor.rb +1 -1
- data/lib/mongo/cluster/reapers/socket_reaper.rb +1 -1
- data/lib/mongo/cluster/topology.rb +12 -2
- data/lib/mongo/cluster/topology/replica_set.rb +9 -1
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/cluster/topology/unknown.rb +1 -1
- data/lib/mongo/collection.rb +75 -19
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/builder.rb +1 -1
- data/lib/mongo/collection/view/builder/aggregation.rb +3 -3
- data/lib/mongo/collection/view/builder/find_command.rb +1 -1
- data/lib/mongo/collection/view/builder/flags.rb +1 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/builder/modifiers.rb +1 -1
- data/lib/mongo/collection/view/builder/op_query.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +193 -17
- data/lib/mongo/collection/view/change_stream/retryable.rb +3 -20
- data/lib/mongo/collection/view/explainable.rb +1 -1
- data/lib/mongo/collection/view/immutable.rb +1 -1
- data/lib/mongo/collection/view/iterable.rb +2 -2
- data/lib/mongo/collection/view/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/readable.rb +108 -29
- data/lib/mongo/collection/view/writable.rb +3 -3
- data/lib/mongo/cursor.rb +44 -4
- 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 +1 -1
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +1 -1
- data/lib/mongo/database.rb +46 -3
- data/lib/mongo/database/view.rb +11 -11
- data/lib/mongo/dbref.rb +1 -1
- data/lib/mongo/error.rb +57 -1
- data/lib/mongo/error/bulk_write_error.rb +2 -2
- data/lib/mongo/error/change_stream_resumable.rb +37 -0
- data/lib/mongo/error/closed_stream.rb +1 -1
- data/lib/mongo/error/extra_file_chunk.rb +1 -1
- data/lib/mongo/error/failed_stringprep_validation.rb +38 -0
- data/lib/mongo/error/file_not_found.rb +1 -1
- data/lib/mongo/error/insufficient_iteration_count.rb +38 -0
- 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 +35 -0
- 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 +82 -0
- 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/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 +1 -1
- data/lib/mongo/error/no_srv_records.rb +1 -1
- data/lib/mongo/error/operation_failure.rb +108 -14
- data/lib/mongo/error/parser.rb +50 -1
- data/lib/mongo/error/socket_error.rb +5 -2
- data/lib/mongo/error/socket_timeout_error.rb +5 -2
- 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 +27 -0
- data/lib/mongo/event.rb +10 -9
- data/lib/mongo/event/base.rb +33 -0
- data/lib/mongo/event/description_changed.rb +2 -2
- data/lib/mongo/event/listeners.rb +1 -1
- data/lib/mongo/event/member_discovered.rb +4 -2
- data/lib/mongo/event/primary_elected.rb +2 -2
- data/lib/mongo/event/publisher.rb +1 -1
- data/lib/mongo/event/standalone_discovered.rb +2 -2
- 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 +3 -3
- data/lib/mongo/grid/file/info.rb +26 -3
- 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/index.rb +1 -1
- data/lib/mongo/index/view.rb +1 -1
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/logger.rb +1 -1
- data/lib/mongo/monitoring.rb +99 -62
- data/lib/mongo/monitoring/command_log_subscriber.rb +2 -2
- data/lib/mongo/monitoring/event.rb +2 -1
- data/lib/mongo/monitoring/event/command_failed.rb +19 -6
- data/lib/mongo/monitoring/event/command_started.rb +14 -3
- data/lib/mongo/monitoring/event/command_succeeded.rb +5 -3
- data/lib/mongo/monitoring/event/secure.rb +1 -1
- data/lib/mongo/monitoring/event/server_closed.rb +2 -2
- data/lib/mongo/monitoring/event/server_description_changed.rb +2 -2
- data/lib/mongo/monitoring/event/server_opening.rb +11 -2
- data/lib/mongo/monitoring/event/topology_changed.rb +13 -2
- data/lib/mongo/monitoring/event/topology_closed.rb +2 -2
- data/lib/mongo/monitoring/event/topology_opening.rb +11 -2
- data/lib/mongo/monitoring/publishable.rb +10 -6
- 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 +1 -1
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +1 -1
- data/lib/mongo/operation/aggregate/op_msg.rb +3 -0
- data/lib/mongo/operation/create/op_msg.rb +9 -0
- data/lib/mongo/operation/create_index/op_msg.rb +9 -0
- data/lib/mongo/operation/create_user/command.rb +1 -1
- data/lib/mongo/operation/create_user/op_msg.rb +10 -1
- data/lib/mongo/operation/delete/op_msg.rb +3 -0
- data/lib/mongo/operation/distinct/op_msg.rb +9 -0
- data/lib/mongo/operation/drop/op_msg.rb +9 -0
- data/lib/mongo/operation/drop_database/op_msg.rb +9 -0
- data/lib/mongo/operation/drop_index/op_msg.rb +9 -0
- data/lib/mongo/operation/explain/op_msg.rb +3 -0
- data/lib/mongo/operation/find/op_msg.rb +3 -0
- data/lib/mongo/operation/get_more.rb +1 -1
- 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 +3 -0
- data/lib/mongo/operation/indexes/op_msg.rb +3 -0
- data/lib/mongo/operation/indexes/result.rb +1 -1
- data/lib/mongo/operation/insert/bulk_result.rb +32 -2
- data/lib/mongo/operation/insert/op_msg.rb +3 -0
- data/lib/mongo/operation/insert/result.rb +1 -1
- data/lib/mongo/operation/kill_cursors/op_msg.rb +9 -0
- data/lib/mongo/operation/list_collections/op_msg.rb +3 -0
- data/lib/mongo/operation/list_collections/result.rb +5 -1
- data/lib/mongo/operation/map_reduce/op_msg.rb +3 -0
- data/lib/mongo/operation/map_reduce/result.rb +1 -1
- data/lib/mongo/operation/parallel_scan/op_msg.rb +3 -0
- data/lib/mongo/operation/remove_user/op_msg.rb +9 -0
- data/lib/mongo/operation/result.rb +27 -14
- data/lib/mongo/operation/shared/executable.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +78 -7
- data/lib/mongo/operation/shared/specifiable.rb +18 -2
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -1
- data/lib/mongo/operation/update/op_msg.rb +3 -0
- data/lib/mongo/operation/update_user/command.rb +1 -1
- data/lib/mongo/operation/update_user/op_msg.rb +10 -1
- data/lib/mongo/operation/users_info/op_msg.rb +3 -0
- data/lib/mongo/options.rb +1 -1
- data/lib/mongo/options/mapper.rb +1 -1
- data/lib/mongo/options/redacted.rb +1 -1
- data/lib/mongo/protocol/bit_vector.rb +1 -1
- data/lib/mongo/protocol/compressed.rb +1 -1
- data/lib/mongo/protocol/delete.rb +1 -1
- data/lib/mongo/protocol/get_more.rb +7 -7
- data/lib/mongo/protocol/insert.rb +1 -1
- data/lib/mongo/protocol/kill_cursors.rb +1 -1
- data/lib/mongo/protocol/message.rb +5 -5
- data/lib/mongo/protocol/msg.rb +9 -7
- data/lib/mongo/protocol/query.rb +1 -1
- data/lib/mongo/protocol/registry.rb +1 -1
- data/lib/mongo/protocol/reply.rb +10 -10
- data/lib/mongo/protocol/serializers.rb +1 -1
- data/lib/mongo/protocol/update.rb +1 -1
- data/lib/mongo/retryable.rb +22 -14
- data/lib/mongo/server.rb +1 -1
- data/lib/mongo/server/connectable.rb +1 -1
- data/lib/mongo/server/connection.rb +16 -4
- data/lib/mongo/server/connection_pool.rb +1 -1
- data/lib/mongo/server/connection_pool/queue.rb +1 -1
- data/lib/mongo/server/context.rb +1 -1
- data/lib/mongo/server/description.rb +14 -2
- data/lib/mongo/server/description/features.rb +10 -9
- data/lib/mongo/server/description/inspector.rb +1 -1
- data/lib/mongo/server/description/inspector/description_changed.rb +1 -1
- data/lib/mongo/server/description/inspector/member_discovered.rb +1 -1
- data/lib/mongo/server/description/inspector/primary_elected.rb +1 -1
- data/lib/mongo/server/description/inspector/standalone_discovered.rb +1 -1
- data/lib/mongo/server/monitor.rb +15 -3
- data/lib/mongo/server/monitor/connection.rb +1 -1
- 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 +7 -2
- data/lib/mongo/session.rb +389 -12
- data/lib/mongo/session/server_session.rb +7 -2
- data/lib/mongo/session/session_pool.rb +1 -1
- data/lib/mongo/socket.rb +1 -1
- data/lib/mongo/socket/ssl.rb +1 -1
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/socket/unix.rb +1 -1
- data/lib/mongo/uri.rb +6 -4
- data/lib/mongo/uri/srv_protocol.rb +1 -1
- data/lib/mongo/version.rb +2 -2
- data/lib/mongo/write_concern.rb +1 -1
- data/lib/mongo/write_concern/acknowledged.rb +1 -1
- data/lib/mongo/write_concern/normalizable.rb +1 -1
- data/lib/mongo/write_concern/unacknowledged.rb +1 -1
- data/mongo.gemspec +4 -1
- data/spec/atlas/atlas_connectivity_spec.rb +54 -0
- data/spec/integration/bulk_insert_spec.rb +78 -0
- data/spec/integration/change_stream_spec.rb +365 -0
- data/spec/integration/command_monitoring_spec.rb +92 -0
- data/spec/lite_spec_helper.rb +63 -0
- data/spec/mongo/address/ipv6_spec.rb +29 -1
- data/spec/mongo/address_spec.rb +34 -0
- data/spec/mongo/auth/scram/conversation_spec.rb +326 -120
- data/spec/mongo/auth/scram/negotiation_spec.rb +574 -0
- data/spec/mongo/auth/scram_spec.rb +107 -38
- data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +113 -0
- data/spec/mongo/auth/stringprep_spec.rb +188 -0
- data/spec/mongo/auth/user/view_spec.rb +5 -2
- data/spec/mongo/auth/user_spec.rb +1 -1
- data/spec/mongo/bulk_write/result_spec.rb +120 -0
- data/spec/mongo/bulk_write_spec.rb +42 -2
- data/spec/mongo/client_spec.rb +121 -9
- data/spec/mongo/cluster/app_metadata_spec.rb +14 -1
- data/spec/mongo/cluster/topology_spec.rb +1 -23
- data/spec/mongo/collection/view/change_stream_spec.rb +62 -180
- data/spec/mongo/collection_spec.rb +45 -12
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +7 -7
- data/spec/mongo/cursor_spec.rb +2 -2
- data/spec/mongo/database_spec.rb +3 -3
- data/spec/mongo/docs_examples_spec.rb +194 -0
- data/spec/mongo/error/operation_failure_spec.rb +152 -0
- data/spec/mongo/error/parser_spec.rb +127 -0
- data/spec/mongo/grid/fs_bucket_spec.rb +32 -0
- data/spec/mongo/grid/stream/write_spec.rb +40 -1
- data/spec/mongo/monitoring/event/command_failed_spec.rb +30 -0
- data/spec/mongo/monitoring/event/command_started_spec.rb +26 -4
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +29 -7
- data/spec/mongo/monitoring_spec.rb +28 -3
- data/spec/mongo/protocol/get_more_spec.rb +2 -2
- data/spec/mongo/retryable_spec.rb +252 -34
- data/spec/mongo/retryable_writes_spec.rb +468 -544
- data/spec/mongo/server/connection_spec.rb +5 -5
- data/spec/mongo/server/description_spec.rb +23 -6
- data/spec/mongo/session/server_session_spec.rb +2 -2
- data/spec/mongo/session/session_pool_spec.rb +2 -2
- data/spec/mongo/transactions_examples_spec.rb +227 -0
- data/spec/mongo/transactions_spec.rb +44 -0
- data/spec/spec_helper.rb +135 -49
- data/spec/spec_tests/change_streams_spec.rb +42 -0
- data/spec/{mongo → spec_tests}/command_monitoring_spec.rb +8 -2
- data/spec/{mongo → spec_tests}/connection_string_spec.rb +1 -1
- data/spec/{mongo → spec_tests}/crud_spec.rb +5 -7
- data/spec/{mongo → spec_tests}/dns_seedlist_discovery_spec.rb +1 -1
- data/spec/{mongo → spec_tests}/gridfs_spec.rb +0 -0
- data/spec/{mongo → spec_tests}/max_staleness_spec.rb +0 -0
- data/spec/spec_tests/retryable_writes_spec.rb +78 -0
- data/spec/{mongo → spec_tests}/sdam_monitoring_spec.rb +4 -3
- data/spec/{mongo → spec_tests}/sdam_spec.rb +7 -7
- data/spec/{mongo → spec_tests}/server_selection_rtt_spec.rb +0 -0
- data/spec/{mongo → spec_tests}/server_selection_spec.rb +0 -0
- data/spec/support/authorization.rb +18 -6
- data/spec/support/change_streams.rb +265 -0
- data/spec/support/change_streams/operation.rb +62 -0
- data/spec/support/change_streams_tests/change-streams-errors.yml +53 -0
- data/spec/support/change_streams_tests/change-streams.yml +299 -0
- data/spec/support/command_monitoring.rb +1 -1
- data/spec/support/command_monitoring/bulkWrite.yml +4 -28
- data/spec/support/command_monitoring/command.yml +19 -0
- data/spec/support/command_monitoring/find.yml +17 -19
- data/spec/support/command_monitoring/insertMany.yml +2 -8
- data/spec/support/command_monitoring/unacknowledgedBulkWrite.yml +34 -0
- data/spec/support/connection_string.rb +1 -1
- data/spec/support/constraints.rb +56 -0
- data/spec/support/crud.rb +9 -4
- data/spec/support/crud/read.rb +24 -3
- data/spec/support/crud/write.rb +7 -2
- data/spec/support/crud_tests/read/count-collation.yml +12 -2
- data/spec/support/crud_tests/read/count.yml +43 -5
- data/spec/support/gridfs.rb +1 -1
- data/spec/support/primary_socket.rb +21 -0
- data/spec/support/retryable_writes_tests/bulkWrite-serverErrors.yml +90 -0
- data/spec/support/retryable_writes_tests/bulkWrite.yml +99 -1
- data/spec/support/retryable_writes_tests/deleteOne-serverErrors.yml +50 -0
- data/spec/support/retryable_writes_tests/deleteOne.yml +10 -1
- data/spec/support/retryable_writes_tests/findOneAndDelete-serverErrors.yml +50 -0
- data/spec/support/retryable_writes_tests/findOneAndDelete.yml +39 -30
- data/spec/support/retryable_writes_tests/findOneAndReplace-serverErrors.yml +54 -0
- data/spec/support/retryable_writes_tests/findOneAndReplace.yml +9 -0
- data/spec/support/retryable_writes_tests/findOneAndUpdate-serverErrors.yml +54 -0
- data/spec/support/retryable_writes_tests/findOneAndUpdate.yml +9 -0
- data/spec/support/retryable_writes_tests/insertMany-serverErrors.yml +59 -0
- data/spec/support/retryable_writes_tests/insertMany.yml +11 -6
- data/spec/support/retryable_writes_tests/insertOne-serverErrors.yml +471 -0
- data/spec/support/retryable_writes_tests/insertOne.yml +9 -0
- data/spec/support/retryable_writes_tests/replaceOne-serverErrors.yml +58 -0
- data/spec/support/retryable_writes_tests/replaceOne.yml +9 -0
- data/spec/support/retryable_writes_tests/updateOne-serverErrors.yml +58 -0
- data/spec/support/retryable_writes_tests/updateOne.yml +71 -53
- data/spec/support/sdam/rs/normalize_case_me.yml +100 -0
- data/spec/support/sdam/sharded/compatible.yml +38 -0
- data/spec/support/sdam/sharded/mongos_disconnect.yml +9 -3
- data/spec/support/sdam/sharded/multiple_mongoses.yml +6 -2
- data/spec/support/sdam/sharded/non_mongos_removed.yml +6 -2
- data/spec/support/sdam/sharded/too_new.yml +36 -0
- data/spec/support/sdam/sharded/too_old.yml +36 -0
- data/spec/support/sdam/single/compatible.yml +26 -0
- data/spec/support/sdam/single/direct_connection_external_ip.yml +3 -1
- data/spec/support/sdam/single/direct_connection_mongos.yml +3 -1
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +3 -1
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +3 -1
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +3 -1
- data/spec/support/sdam/single/direct_connection_slave.yml +3 -1
- data/spec/support/sdam/single/direct_connection_standalone.yml +3 -1
- data/spec/support/sdam/single/not_ok_response.yml +6 -2
- data/spec/support/sdam/single/standalone_removed.yml +3 -1
- data/spec/support/sdam/single/too_new.yml +26 -0
- data/spec/support/sdam/single/too_old.yml +24 -0
- data/spec/support/shared/session.rb +107 -0
- data/spec/support/transactions.rb +391 -0
- data/spec/support/transactions/operation.rb +373 -0
- data/spec/support/transactions_tests/abort.yml +403 -0
- data/spec/support/transactions_tests/bulk.yml +267 -0
- data/spec/support/transactions_tests/causal-consistency.yml +173 -0
- data/spec/support/transactions_tests/commit.yml +593 -0
- data/spec/support/transactions_tests/delete.yml +184 -0
- data/spec/support/transactions_tests/error-labels.yml +948 -0
- data/spec/support/transactions_tests/errors.yml +125 -0
- data/spec/support/transactions_tests/findOneAndDelete.yml +126 -0
- data/spec/support/transactions_tests/findOneAndReplace.yml +140 -0
- data/spec/support/transactions_tests/findOneAndUpdate.yml +228 -0
- data/spec/support/transactions_tests/insert.yml +264 -0
- data/spec/support/transactions_tests/isolation.yml +125 -0
- data/spec/support/transactions_tests/read-pref.yml +340 -0
- data/spec/support/transactions_tests/reads.yml +298 -0
- data/spec/support/transactions_tests/retryable-abort.yml +1292 -0
- data/spec/support/transactions_tests/retryable-commit.yml +1332 -0
- data/spec/support/transactions_tests/retryable-writes.yml +208 -0
- data/spec/support/transactions_tests/run-command.yml +189 -0
- data/spec/support/transactions_tests/transaction-options.yml +877 -0
- data/spec/support/transactions_tests/update.yml +246 -0
- data/spec/support/transactions_tests/write-concern.yml +236 -0
- metadata +494 -359
- metadata.gz.sig +0 -0
- data/lib/csasl/csasl.bundle +0 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright (C) 2018 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
class Error
|
17
|
+
|
18
|
+
# A module signifying the error is always write retryable.
|
19
|
+
#
|
20
|
+
# @since 2.6.0
|
21
|
+
module WriteRetryable
|
22
|
+
def write_retryable?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mongo/event.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2018 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.
|
@@ -12,14 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require 'mongo/event/listeners'
|
16
|
-
require 'mongo/event/publisher'
|
17
|
-
require 'mongo/event/subscriber'
|
18
|
-
require 'mongo/event/primary_elected'
|
19
|
-
require 'mongo/event/member_discovered'
|
20
|
-
require 'mongo/event/description_changed'
|
21
|
-
require 'mongo/event/standalone_discovered'
|
22
|
-
|
23
15
|
module Mongo
|
24
16
|
module Event
|
25
17
|
|
@@ -46,3 +38,12 @@ module Mongo
|
|
46
38
|
DESCRIPTION_CHANGED = 'description_changed'.freeze
|
47
39
|
end
|
48
40
|
end
|
41
|
+
|
42
|
+
require 'mongo/event/base'
|
43
|
+
require 'mongo/event/listeners'
|
44
|
+
require 'mongo/event/publisher'
|
45
|
+
require 'mongo/event/subscriber'
|
46
|
+
require 'mongo/event/primary_elected'
|
47
|
+
require 'mongo/event/member_discovered'
|
48
|
+
require 'mongo/event/description_changed'
|
49
|
+
require 'mongo/event/standalone_discovered'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (C) 2018 MongoDB, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Mongo
|
16
|
+
module Event
|
17
|
+
|
18
|
+
# Base class for all events.
|
19
|
+
#
|
20
|
+
# @since 2.6.0
|
21
|
+
class Base
|
22
|
+
# Returns a concise yet useful summary of the event.
|
23
|
+
# Meant to be overridden in derived classes.
|
24
|
+
#
|
25
|
+
# @return [ String ] String summary of the event.
|
26
|
+
#
|
27
|
+
# @since 2.6.0
|
28
|
+
def inspect
|
29
|
+
"#<#{self.class}>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
# Copyright (C) 2014-
|
2
|
+
# Copyright (C) 2014-2018 MongoDB, Inc.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -19,7 +19,7 @@ module Mongo
|
|
19
19
|
# This handles a change in description.
|
20
20
|
#
|
21
21
|
# @since 2.0.6
|
22
|
-
class DescriptionChanged
|
22
|
+
class DescriptionChanged < Base
|
23
23
|
include Monitoring::Publishable
|
24
24
|
|
25
25
|
# @return [ Mongo::Cluster ] cluster The cluster.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 MongoDB, Inc.
|
1
|
+
# Copyright (C) 2015-2018 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.
|
@@ -12,13 +12,15 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
require 'mongo/monitoring/publishable'
|
16
|
+
|
15
17
|
module Mongo
|
16
18
|
module Event
|
17
19
|
|
18
20
|
# This handles member discovered events for server descriptions.
|
19
21
|
#
|
20
22
|
# @since 2.4.0
|
21
|
-
class MemberDiscovered
|
23
|
+
class MemberDiscovered < Base
|
22
24
|
include Monitoring::Publishable
|
23
25
|
|
24
26
|
# @return [ Mongo::Cluster ] cluster The cluster.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 MongoDB, Inc.
|
1
|
+
# Copyright (C) 2015-2018 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.
|
@@ -20,7 +20,7 @@ module Mongo
|
|
20
20
|
# @since 2.0.0
|
21
21
|
#
|
22
22
|
# @deprecated. Will be removed in 3.0
|
23
|
-
class PrimaryElected
|
23
|
+
class PrimaryElected < Base
|
24
24
|
|
25
25
|
# @return [ Mongo::Cluster ] cluster The cluster.
|
26
26
|
attr_reader :cluster
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 MongoDB, Inc.
|
1
|
+
# Copyright (C) 2015-2018 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.
|
@@ -18,7 +18,7 @@ module Mongo
|
|
18
18
|
# This handles when a standalone is discovered.
|
19
19
|
#
|
20
20
|
# @since 2.0.6
|
21
|
-
class StandaloneDiscovered
|
21
|
+
class StandaloneDiscovered < Base
|
22
22
|
|
23
23
|
# @return [ Mongo::Cluster ] cluster The cluster.
|
24
24
|
attr_reader :cluster
|
data/lib/mongo/grid.rb
CHANGED
data/lib/mongo/grid/file.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2018 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.
|
@@ -173,11 +173,11 @@ module Mongo
|
|
173
173
|
io = StringIO.new(io) if io.is_a?(String)
|
174
174
|
parts = Enumerator.new { |y| y << io.read(file_info.chunk_size) until io.eof? }
|
175
175
|
parts.map.with_index do |bytes, n|
|
176
|
-
file_info.
|
176
|
+
file_info.update_md5(bytes)
|
177
177
|
Chunk.new(
|
178
178
|
data: BSON::Binary.new(bytes),
|
179
179
|
files_id: file_info.id,
|
180
|
-
n: n + offset
|
180
|
+
n: n + offset
|
181
181
|
)
|
182
182
|
end
|
183
183
|
end
|
data/lib/mongo/grid/file/info.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2018 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.
|
@@ -134,8 +134,8 @@ module Mongo
|
|
134
134
|
#
|
135
135
|
# @since 2.0.0
|
136
136
|
def initialize(document)
|
137
|
+
@client_md5 = Digest::MD5.new unless document[:disable_md5] == true
|
137
138
|
@document = default_document.merge(Options::Mapper.transform(document, MAPPINGS))
|
138
|
-
@client_md5 = Digest::MD5.new
|
139
139
|
end
|
140
140
|
|
141
141
|
# Get a readable inspection for the object.
|
@@ -184,10 +184,31 @@ module Mongo
|
|
184
184
|
# @return [ String ] The md5 hash as a string.
|
185
185
|
#
|
186
186
|
# @since 2.0.0
|
187
|
+
#
|
188
|
+
# @deprecated as of 2.6.0
|
187
189
|
def md5
|
188
190
|
document[:md5] || @client_md5
|
189
191
|
end
|
190
192
|
|
193
|
+
# Update the md5 hash if there is one.
|
194
|
+
#
|
195
|
+
# @example Update the md5 hash.
|
196
|
+
# file_info.update_md5(bytes)
|
197
|
+
#
|
198
|
+
# @note This method is transitional and is provided for backwards compatibility.
|
199
|
+
# It will be removed when md5 support is deprecated entirely.
|
200
|
+
#
|
201
|
+
# @param [ String ] The bytes to use to update the digest.
|
202
|
+
#
|
203
|
+
# @return [ Digest::MD5 ] The md5 hash object.
|
204
|
+
#
|
205
|
+
# @since 2.6.0
|
206
|
+
#
|
207
|
+
# @deprecated as of 2.6.0
|
208
|
+
def update_md5(bytes)
|
209
|
+
md5.update(bytes) if md5
|
210
|
+
end
|
211
|
+
|
191
212
|
# Convert the file information document to BSON for storage.
|
192
213
|
#
|
193
214
|
# @note If no md5 exists in the file information document (it was loaded
|
@@ -203,7 +224,9 @@ module Mongo
|
|
203
224
|
#
|
204
225
|
# @since 2.0.0
|
205
226
|
def to_bson(buffer = BSON::ByteBuffer.new, validating_keys = BSON::Config.validating_keys?)
|
206
|
-
document[:md5]
|
227
|
+
if @client_md5 && !document[:md5]
|
228
|
+
document[:md5] = @client_md5.hexdigest
|
229
|
+
end
|
207
230
|
document.to_bson(buffer)
|
208
231
|
end
|
209
232
|
|
data/lib/mongo/grid/fs_bucket.rb
CHANGED
data/lib/mongo/grid/stream.rb
CHANGED
data/lib/mongo/index.rb
CHANGED
data/lib/mongo/index/view.rb
CHANGED
data/lib/mongo/loggable.rb
CHANGED
data/lib/mongo/logger.rb
CHANGED
data/lib/mongo/monitoring.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015-
|
1
|
+
# Copyright (C) 2015-2018 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.
|
@@ -12,16 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require 'mongo/monitoring/event'
|
16
|
-
require 'mongo/monitoring/publishable'
|
17
|
-
require 'mongo/monitoring/command_log_subscriber'
|
18
|
-
require 'mongo/monitoring/sdam_log_subscriber'
|
19
|
-
require 'mongo/monitoring/server_description_changed_log_subscriber'
|
20
|
-
require 'mongo/monitoring/server_closed_log_subscriber'
|
21
|
-
require 'mongo/monitoring/server_opening_log_subscriber'
|
22
|
-
require 'mongo/monitoring/topology_changed_log_subscriber'
|
23
|
-
require 'mongo/monitoring/topology_opening_log_subscriber'
|
24
|
-
|
25
15
|
module Mongo
|
26
16
|
|
27
17
|
# The class defines behaviour for the performance monitoring API.
|
@@ -81,15 +71,22 @@ module Mongo
|
|
81
71
|
end
|
82
72
|
end
|
83
73
|
|
84
|
-
#
|
74
|
+
# Contains subscription methods common between monitoring and
|
75
|
+
# global event subscriptions.
|
85
76
|
#
|
86
|
-
# @since 2.
|
87
|
-
module
|
88
|
-
extend self
|
89
|
-
|
77
|
+
# @since 2.6.0
|
78
|
+
module Subscribable
|
90
79
|
# Subscribe a listener to an event topic.
|
91
80
|
#
|
81
|
+
# @note It is possible to subscribe the same listener to the same topic
|
82
|
+
# multiple times, in which case the listener will be invoked as many
|
83
|
+
# times as it is subscribed and to unsubscribe it the same number
|
84
|
+
# of unsubscribe calls will be needed.
|
85
|
+
#
|
92
86
|
# @example Subscribe to the topic.
|
87
|
+
# monitoring.subscribe(QUERY, subscriber)
|
88
|
+
#
|
89
|
+
# @example Subscribe to the topic globally.
|
93
90
|
# Monitoring::Global.subscribe(QUERY, subscriber)
|
94
91
|
#
|
95
92
|
# @param [ String ] topic The event topic.
|
@@ -100,10 +97,50 @@ module Mongo
|
|
100
97
|
subscribers_for(topic).push(subscriber)
|
101
98
|
end
|
102
99
|
|
103
|
-
#
|
100
|
+
# Unsubscribe a listener from an event topic.
|
101
|
+
#
|
102
|
+
# If the listener was subscribed to the event topic multiple times,
|
103
|
+
# this call removes a single subscription.
|
104
|
+
#
|
105
|
+
# If the listener was not subscribed to the topic, this operation
|
106
|
+
# is a no-op and no exceptions are raised.
|
107
|
+
#
|
108
|
+
# @note Global subscriber registry is separate from per-client
|
109
|
+
# subscriber registry. The same subscriber can be subscribed to
|
110
|
+
# events from a particular client as well as globally; unsubscribing
|
111
|
+
# globally will not unsubscribe that subscriber from the client
|
112
|
+
# it was explicitly subscribed to.
|
113
|
+
#
|
114
|
+
# @note Currently the list of global subscribers is copied into
|
115
|
+
# a client whenever the client is created. Thus unsubscribing a
|
116
|
+
# subscriber globally has no effect for existing clients - they will
|
117
|
+
# continue sending events to the unsubscribed subscriber.
|
118
|
+
#
|
119
|
+
# @example Unsubscribe from the topic.
|
120
|
+
# monitoring.unsubscribe(QUERY, subscriber)
|
121
|
+
#
|
122
|
+
# @example Unsubscribe from the topic globally.
|
123
|
+
# Mongo::Monitoring::Global.unsubscribe(QUERY, subscriber)
|
124
|
+
#
|
125
|
+
# @param [ String ] topic The event topic.
|
126
|
+
# @param [ Object ] subscriber The subscriber to be unsubscribed.
|
127
|
+
#
|
128
|
+
# @since 2.6.0
|
129
|
+
def unsubscribe(topic, subscriber)
|
130
|
+
subs = subscribers_for(topic)
|
131
|
+
index = subs.index(subscriber)
|
132
|
+
if index
|
133
|
+
subs.delete_at(index)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Get all the subscribers.
|
138
|
+
#
|
139
|
+
# @example Get all the subscribers.
|
140
|
+
# monitoring.subscribers
|
104
141
|
#
|
105
142
|
# @example Get all the global subscribers.
|
106
|
-
# Monitoring::Global.subscribers
|
143
|
+
# Mongo::Monitoring::Global.subscribers
|
107
144
|
#
|
108
145
|
# @return [ Hash<String, Object> ] The subscribers.
|
109
146
|
#
|
@@ -112,6 +149,23 @@ module Mongo
|
|
112
149
|
@subscribers ||= {}
|
113
150
|
end
|
114
151
|
|
152
|
+
# Determine if there are any subscribers for a particular event.
|
153
|
+
#
|
154
|
+
# @example Are there subscribers?
|
155
|
+
# monitoring.subscribers?(COMMAND)
|
156
|
+
#
|
157
|
+
# @example Are there global subscribers?
|
158
|
+
# Mongo::Monitoring::Global.subscribers?(COMMAND)
|
159
|
+
#
|
160
|
+
# @param [ String ] topic The event topic.
|
161
|
+
#
|
162
|
+
# @return [ true, false ] If there are subscribers for the topic.
|
163
|
+
#
|
164
|
+
# @since 2.1.0
|
165
|
+
def subscribers?(topic)
|
166
|
+
!subscribers_for(topic).empty?
|
167
|
+
end
|
168
|
+
|
115
169
|
private
|
116
170
|
|
117
171
|
def subscribers_for(topic)
|
@@ -119,6 +173,20 @@ module Mongo
|
|
119
173
|
end
|
120
174
|
end
|
121
175
|
|
176
|
+
# Allows subscribing to events for all Mongo clients.
|
177
|
+
#
|
178
|
+
# @note Global subscriptions must be established prior to creating
|
179
|
+
# clients. When a client is constructed it copies subscribers from
|
180
|
+
# the Global module; subsequent subscriptions or unsubscriptions
|
181
|
+
# on the Global module have no effect on already created clients.
|
182
|
+
#
|
183
|
+
# @since 2.1.0
|
184
|
+
module Global
|
185
|
+
extend Subscribable
|
186
|
+
end
|
187
|
+
|
188
|
+
include Subscribable
|
189
|
+
|
122
190
|
# Initialize the monitoring.
|
123
191
|
#
|
124
192
|
# @api private
|
@@ -126,7 +194,9 @@ module Mongo
|
|
126
194
|
# @example Create the new monitoring.
|
127
195
|
# Monitoring.new(:monitoring => true)
|
128
196
|
#
|
129
|
-
# @param [ Hash ] options
|
197
|
+
# @param [ Hash ] options Options. Client constructor forwards its
|
198
|
+
# options to Monitoring constructor, although Monitoring recognizes
|
199
|
+
# only a subset of the options recognized by Client.
|
130
200
|
#
|
131
201
|
# @since 2.1.0
|
132
202
|
def initialize(options = {})
|
@@ -184,53 +254,20 @@ module Mongo
|
|
184
254
|
subscribers_for(topic).each{ |subscriber| subscriber.failed(event) }
|
185
255
|
end
|
186
256
|
|
187
|
-
# Subscribe a listener to an event topic.
|
188
|
-
#
|
189
|
-
# @example Subscribe to the topic.
|
190
|
-
# monitoring.subscribe(QUERY, subscriber)
|
191
|
-
#
|
192
|
-
# @param [ String ] topic The event topic.
|
193
|
-
# @param [ Object ] subscriber The subscriber to handle the event.
|
194
|
-
#
|
195
|
-
# @since 2.1.0
|
196
|
-
def subscribe(topic, subscriber)
|
197
|
-
subscribers_for(topic).push(subscriber)
|
198
|
-
end
|
199
|
-
|
200
|
-
# Get all the subscribers.
|
201
|
-
#
|
202
|
-
# @example Get all the subscribers.
|
203
|
-
# monitoring.subscribers
|
204
|
-
#
|
205
|
-
# @return [ Hash<String, Object> ] The subscribers.
|
206
|
-
#
|
207
|
-
# @since 2.1.0
|
208
|
-
def subscribers
|
209
|
-
@subscribers ||= {}
|
210
|
-
end
|
211
|
-
|
212
|
-
# Determine if there are any subscribers for a particular event.
|
213
|
-
#
|
214
|
-
# @example Are there subscribers?
|
215
|
-
# monitoring.subscribers?(COMMAND)
|
216
|
-
#
|
217
|
-
# @param [ String ] topic The event topic.
|
218
|
-
#
|
219
|
-
# @return [ true, false ] If there are subscribers for the topic.
|
220
|
-
#
|
221
|
-
# @since 2.1.0
|
222
|
-
def subscribers?(topic)
|
223
|
-
!subscribers_for(topic).empty?
|
224
|
-
end
|
225
|
-
|
226
257
|
private
|
227
258
|
|
228
259
|
def initialize_copy(original)
|
229
260
|
@subscribers = original.subscribers.dup
|
230
261
|
end
|
231
|
-
|
232
|
-
def subscribers_for(topic)
|
233
|
-
subscribers[topic] ||= []
|
234
|
-
end
|
235
262
|
end
|
236
263
|
end
|
264
|
+
|
265
|
+
require 'mongo/monitoring/event'
|
266
|
+
require 'mongo/monitoring/publishable'
|
267
|
+
require 'mongo/monitoring/command_log_subscriber'
|
268
|
+
require 'mongo/monitoring/sdam_log_subscriber'
|
269
|
+
require 'mongo/monitoring/server_description_changed_log_subscriber'
|
270
|
+
require 'mongo/monitoring/server_closed_log_subscriber'
|
271
|
+
require 'mongo/monitoring/server_opening_log_subscriber'
|
272
|
+
require 'mongo/monitoring/topology_changed_log_subscriber'
|
273
|
+
require 'mongo/monitoring/topology_opening_log_subscriber'
|