mongo 2.2.7 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +1 -1
- data/lib/mongo.rb +1 -1
- data/lib/mongo/address.rb +1 -1
- 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 +1 -1
- data/lib/mongo/auth/cr.rb +1 -1
- data/lib/mongo/auth/ldap.rb +1 -1
- data/lib/mongo/auth/roles.rb +1 -1
- data/lib/mongo/auth/user.rb +1 -1
- data/lib/mongo/auth/user/view.rb +5 -5
- data/lib/mongo/auth/x509.rb +1 -1
- data/lib/mongo/bson.rb +1 -1
- data/lib/mongo/bulk_write.rb +4 -4
- 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 +1 -1
- 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 +2 -2
- data/lib/mongo/cluster.rb +15 -3
- data/lib/mongo/cluster/cursor_reaper.rb +174 -0
- data/lib/mongo/cluster/topology.rb +1 -1
- data/lib/mongo/cluster/topology/replica_set.rb +1 -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 +5 -4
- data/lib/mongo/collection/view.rb +4 -4
- 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 +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/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 +3 -3
- data/lib/mongo/collection/view/readable.rb +23 -6
- data/lib/mongo/collection/view/writable.rb +3 -3
- data/lib/mongo/cursor.rb +50 -7
- 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 +29 -1
- data/lib/mongo/cursor/builder/op_get_more.rb +1 -1
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +29 -1
- data/lib/mongo/database.rb +4 -4
- data/lib/mongo/database/view.rb +2 -2
- data/lib/mongo/dbref.rb +4 -3
- data/lib/mongo/error.rb +1 -1
- data/lib/mongo/error/bulk_write_error.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/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_nonce.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_signature.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/missing_file_chunk.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 +4 -2
- data/lib/mongo/error/operation_failure.rb +1 -1
- data/lib/mongo/error/parser.rb +1 -1
- 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/unsupported_features.rb +1 -1
- data/lib/mongo/event.rb +1 -1
- data/lib/mongo/event/description_changed.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 +6 -2
- data/lib/mongo/grid/file/chunk.rb +6 -4
- data/lib/mongo/grid/file/info.rb +7 -3
- data/lib/mongo/grid/fs_bucket.rb +12 -6
- data/lib/mongo/grid/stream.rb +1 -1
- data/lib/mongo/grid/stream/read.rb +2 -4
- data/lib/mongo/grid/stream/write.rb +4 -3
- data/lib/mongo/index.rb +1 -1
- data/lib/mongo/index/view.rb +5 -4
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/logger.rb +1 -1
- data/lib/mongo/monitoring.rb +1 -1
- data/lib/mongo/operation.rb +1 -1
- data/lib/mongo/operation/commands.rb +1 -1
- data/lib/mongo/operation/commands/aggregate.rb +7 -7
- data/lib/mongo/operation/commands/aggregate/result.rb +1 -1
- data/lib/mongo/operation/commands/collections_info.rb +10 -9
- data/lib/mongo/operation/commands/collections_info/result.rb +1 -1
- data/lib/mongo/operation/commands/command.rb +1 -1
- data/lib/mongo/operation/commands/indexes.rb +12 -11
- data/lib/mongo/operation/commands/list_collections.rb +1 -1
- data/lib/mongo/operation/commands/list_collections/result.rb +1 -1
- data/lib/mongo/operation/commands/list_indexes.rb +1 -1
- data/lib/mongo/operation/commands/list_indexes/result.rb +1 -1
- data/lib/mongo/operation/commands/map_reduce.rb +1 -1
- data/lib/mongo/operation/commands/map_reduce/result.rb +1 -1
- data/lib/mongo/operation/commands/user_query.rb +11 -10
- data/lib/mongo/operation/commands/users_info.rb +2 -2
- data/lib/mongo/operation/commands/users_info/result.rb +1 -1
- data/lib/mongo/operation/executable.rb +8 -7
- data/lib/mongo/operation/kill_cursors.rb +2 -2
- data/lib/mongo/operation/limited.rb +1 -1
- data/lib/mongo/operation/read.rb +1 -1
- data/lib/mongo/operation/read/get_more.rb +2 -2
- data/lib/mongo/operation/read/query.rb +1 -1
- data/lib/mongo/operation/read/query/result.rb +1 -1
- data/lib/mongo/operation/read_preference.rb +10 -10
- data/lib/mongo/operation/result.rb +1 -1
- data/lib/mongo/operation/specifiable.rb +2 -2
- data/lib/mongo/operation/write.rb +1 -1
- data/lib/mongo/operation/write/bulk.rb +1 -1
- data/lib/mongo/operation/write/bulk/bulkable.rb +9 -9
- data/lib/mongo/operation/write/bulk/delete.rb +3 -3
- data/lib/mongo/operation/write/bulk/delete/result.rb +1 -1
- data/lib/mongo/operation/write/bulk/insert.rb +5 -5
- data/lib/mongo/operation/write/bulk/insert/result.rb +1 -1
- data/lib/mongo/operation/write/bulk/legacy_mergable.rb +1 -1
- data/lib/mongo/operation/write/bulk/mergable.rb +1 -1
- data/lib/mongo/operation/write/bulk/update.rb +3 -3
- data/lib/mongo/operation/write/bulk/update/result.rb +1 -1
- data/lib/mongo/operation/write/command.rb +1 -1
- data/lib/mongo/operation/write/command/create_index.rb +1 -1
- data/lib/mongo/operation/write/command/create_user.rb +1 -1
- data/lib/mongo/operation/write/command/delete.rb +1 -1
- data/lib/mongo/operation/write/command/drop_index.rb +1 -1
- data/lib/mongo/operation/write/command/insert.rb +11 -1
- data/lib/mongo/operation/write/command/remove_user.rb +1 -1
- data/lib/mongo/operation/write/command/update.rb +1 -1
- data/lib/mongo/operation/write/command/update_user.rb +1 -1
- data/lib/mongo/operation/write/command/writable.rb +7 -6
- data/lib/mongo/operation/write/create_index.rb +1 -1
- data/lib/mongo/operation/write/create_user.rb +1 -1
- data/lib/mongo/operation/write/delete.rb +1 -1
- data/lib/mongo/operation/write/delete/result.rb +1 -1
- data/lib/mongo/operation/write/drop_index.rb +5 -5
- data/lib/mongo/operation/write/gle.rb +3 -3
- data/lib/mongo/operation/write/idable.rb +1 -1
- data/lib/mongo/operation/write/insert.rb +5 -5
- data/lib/mongo/operation/write/insert/result.rb +1 -1
- data/lib/mongo/operation/write/remove_user.rb +1 -1
- data/lib/mongo/operation/write/update.rb +1 -1
- data/lib/mongo/operation/write/update/result.rb +1 -1
- data/lib/mongo/operation/write/update_user.rb +1 -1
- data/lib/mongo/operation/write/write_command_enabled.rb +10 -9
- data/lib/mongo/protocol/bit_vector.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 +5 -1
- data/lib/mongo/protocol/kill_cursors.rb +1 -1
- data/lib/mongo/protocol/message.rb +9 -5
- data/lib/mongo/protocol/query.rb +1 -1
- data/lib/mongo/protocol/reply.rb +1 -1
- data/lib/mongo/protocol/serializers.rb +8 -8
- data/lib/mongo/protocol/update.rb +1 -1
- data/lib/mongo/server.rb +40 -3
- data/lib/mongo/server/connectable.rb +1 -1
- data/lib/mongo/server/connection.rb +4 -2
- 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 +3 -1
- data/lib/mongo/server/description.rb +1 -1
- data/lib/mongo/server/description/inspector/description_changed.rb +1 -1
- data/lib/mongo/server/monitor.rb +1 -1
- data/lib/mongo/server_selector.rb +2 -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 +12 -7
- 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 +1 -1
- data/lib/mongo/version.rb +2 -2
- 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 +1 -1
- data/spec/mongo/client_spec.rb +2 -2
- data/spec/mongo/cluster/cursor_reaper_spec.rb +216 -0
- data/spec/mongo/cluster_spec.rb +36 -5
- data/spec/mongo/collection/view/aggregation_spec.rb +2 -2
- data/spec/mongo/collection/view/map_reduce_spec.rb +2 -2
- data/spec/mongo/collection/view/readable_spec.rb +203 -5
- data/spec/mongo/collection/view_spec.rb +10 -0
- data/spec/mongo/collection_spec.rb +64 -18
- data/spec/mongo/cursor_spec.rb +89 -0
- data/spec/mongo/database_spec.rb +79 -13
- data/spec/mongo/grid/fs_bucket_spec.rb +119 -1
- data/spec/mongo/grid/stream/write_spec.rb +63 -12
- data/spec/mongo/index/view_spec.rb +19 -0
- data/spec/mongo/operation/commands/aggregate_spec.rb +10 -7
- data/spec/mongo/operation/commands/collections_info_spec.rb +1 -1
- data/spec/mongo/operation/commands/command_spec.rb +3 -3
- data/spec/mongo/operation/commands/indexes_spec.rb +1 -1
- data/spec/mongo/operation/commands/map_reduce_spec.rb +2 -2
- data/spec/mongo/operation/kill_cursors_spec.rb +10 -19
- data/spec/mongo/operation/read/get_more_spec.rb +13 -25
- data/spec/mongo/operation/read/query_spec.rb +26 -30
- data/spec/mongo/operation/read_preference_spec.rb +11 -11
- data/spec/mongo/operation/specifiable_spec.rb +31 -0
- data/spec/mongo/operation/write/bulk/delete_spec.rb +16 -18
- data/spec/mongo/operation/write/bulk/insert_spec.rb +17 -18
- data/spec/mongo/operation/write/bulk/update_spec.rb +20 -25
- data/spec/mongo/operation/write/command/delete_spec.rb +26 -32
- data/spec/mongo/operation/write/command/insert_spec.rb +24 -31
- data/spec/mongo/operation/write/command/update_spec.rb +24 -32
- data/spec/mongo/operation/write/create_index_spec.rb +4 -4
- data/spec/mongo/operation/write/create_user_spec.rb +3 -3
- data/spec/mongo/operation/write/delete_spec.rb +51 -22
- data/spec/mongo/operation/write/drop_index_spec.rb +2 -2
- data/spec/mongo/operation/write/insert_spec.rb +42 -11
- data/spec/mongo/operation/write/remove_user_spec.rb +4 -4
- data/spec/mongo/operation/write/update_spec.rb +34 -6
- data/spec/mongo/operation/write/update_user_spec.rb +1 -1
- data/spec/mongo/server/connection_spec.rb +22 -14
- data/spec/mongo/server_selection_spec.rb +2 -2
- data/spec/mongo/server_selector/nearest_spec.rb +4 -4
- data/spec/mongo/server_selector/primary_preferred_spec.rb +4 -4
- data/spec/mongo/server_selector/primary_spec.rb +2 -2
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +4 -4
- data/spec/mongo/server_selector/secondary_spec.rb +3 -3
- data/spec/mongo/server_selector_spec.rb +82 -3
- data/spec/mongo/server_spec.rb +0 -20
- data/spec/support/command_monitoring.rb +1 -1
- data/spec/support/connection_string.rb +1 -1
- data/spec/support/crud.rb +1 -1
- data/spec/support/crud/read.rb +1 -1
- data/spec/support/crud/write.rb +1 -1
- data/spec/support/gridfs.rb +1 -1
- data/spec/support/shared/server_selector.rb +3 -3
- metadata +7 -10
- metadata.gz.sig +0 -0
- data/lib/csasl/csasl.bundle +0 -0
- data/spec/mongo/operation/write/response_spec.rb +0 -85
- data/spec/support/shared/operation.rb +0 -100
data/lib/mongo/grid/fs_bucket.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -100,11 +100,14 @@ module Mongo
|
|
100
100
|
# @return [ Grid::File ] The file.
|
101
101
|
#
|
102
102
|
# @since 2.0.0
|
103
|
+
#
|
104
|
+
# @deprecated Please use #find instead with a limit of -1.
|
105
|
+
# Will be removed in version 3.0.
|
103
106
|
def find_one(selector = nil)
|
104
107
|
file_info = files_collection.find(selector).first
|
105
108
|
return nil unless file_info
|
106
109
|
chunks = chunks_collection.find(:files_id => file_info[:_id]).sort(:n => 1)
|
107
|
-
Grid::File.new(chunks.to_a, file_info)
|
110
|
+
Grid::File.new(chunks.to_a, Options::Mapper.transform(file_info, Grid::File::Info::MAPPINGS.invert))
|
108
111
|
end
|
109
112
|
|
110
113
|
# Insert a single file into the GridFS.
|
@@ -117,6 +120,9 @@ module Mongo
|
|
117
120
|
# @return [ BSON::ObjectId ] The file id.
|
118
121
|
#
|
119
122
|
# @since 2.0.0
|
123
|
+
#
|
124
|
+
# @deprecated Please use #upload_from_stream or #open_upload_stream instead.
|
125
|
+
# Will be removed in version 3.0.
|
120
126
|
def insert_one(file)
|
121
127
|
@indexes ||= ensure_indexes!
|
122
128
|
chunks_collection.insert_many(file.chunks)
|
@@ -331,6 +337,7 @@ module Mongo
|
|
331
337
|
# @param [ String ] filename The filename of the file to upload.
|
332
338
|
# @param [ Hash ] opts The options for the write stream.
|
333
339
|
#
|
340
|
+
# @option opts [ Object ] :file_id An optional unique file id. An ObjectId is generated otherwise.
|
334
341
|
# @option opts [ Integer ] :chunk_size Override the default chunk size.
|
335
342
|
# @option opts [ Hash ] :write The write concern.
|
336
343
|
# @option opts [ Hash ] :metadata User data for the 'metadata' field of the files
|
@@ -360,12 +367,13 @@ module Mongo
|
|
360
367
|
# document for the filename in the files collection.
|
361
368
|
#
|
362
369
|
# @example Upload a file to the GridFS bucket.
|
363
|
-
# fs.upload_from_stream('a-file.txt')
|
370
|
+
# fs.upload_from_stream('a-file.txt', file)
|
364
371
|
#
|
365
372
|
# @param [ String ] filename The filename of the file to upload.
|
366
373
|
# @param [ IO ] io The source io stream to upload from.
|
367
374
|
# @param [ Hash ] opts The options for the write stream.
|
368
375
|
#
|
376
|
+
# @option opts [ Object ] :file_id An optional unique file id. An ObjectId is generated otherwise.
|
369
377
|
# @option opts [ Integer ] :chunk_size Override the default chunk size.
|
370
378
|
# @option opts [ Hash ] :write The write concern.
|
371
379
|
# @option opts [ Hash ] :metadata User data for the 'metadata' field of the files
|
@@ -401,9 +409,7 @@ module Mongo
|
|
401
409
|
#
|
402
410
|
# @since 2.1.0
|
403
411
|
def read_preference
|
404
|
-
@read_preference ||= @options[:read]
|
405
|
-
ServerSelector.get(Options::Redacted.new((@options[:read] || {}).merge(client.options))) :
|
406
|
-
database.read_preference
|
412
|
+
@read_preference ||= ServerSelector.get(@options[:read] || database.read_preference)
|
407
413
|
end
|
408
414
|
|
409
415
|
# Get the write concern.
|
data/lib/mongo/grid/stream.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -133,9 +133,7 @@ module Mongo
|
|
133
133
|
#
|
134
134
|
# @since 2.1.0
|
135
135
|
def read_preference
|
136
|
-
@read_preference ||= @options[:read]
|
137
|
-
ServerSelector.get(Options::Redacted.new((@options[:read] || {}).merge(fs.options))) :
|
138
|
-
fs.read_preference
|
136
|
+
@read_preference ||= ServerSelector.get(@options[:read] || fs.read_preference)
|
139
137
|
end
|
140
138
|
|
141
139
|
# Get the files collection file information document for the file being read.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -27,7 +27,7 @@ module Mongo
|
|
27
27
|
# @since 2.1.0
|
28
28
|
attr_reader :fs
|
29
29
|
|
30
|
-
# @return [
|
30
|
+
# @return [ Object ] file_id The id of the file being uploaded.
|
31
31
|
#
|
32
32
|
# @since 2.1.0
|
33
33
|
attr_reader :file_id
|
@@ -50,6 +50,7 @@ module Mongo
|
|
50
50
|
# @param [ FSBucket ] fs The GridFS bucket object.
|
51
51
|
# @param [ Hash ] options The write stream options.
|
52
52
|
#
|
53
|
+
# @option opts [ Object ] :file_id The file id. An ObjectId is generated otherwise.
|
53
54
|
# @option opts [ Integer ] :chunk_size Override the default chunk size.
|
54
55
|
# @option opts [ Hash ] :write The write concern.
|
55
56
|
# @option opts [ Hash ] :metadata User data for the 'metadata' field of the files collection document.
|
@@ -63,7 +64,7 @@ module Mongo
|
|
63
64
|
@fs = fs
|
64
65
|
@length = 0
|
65
66
|
@n = 0
|
66
|
-
@file_id = BSON::ObjectId.new
|
67
|
+
@file_id = options[:file_id] || BSON::ObjectId.new
|
67
68
|
@options = options
|
68
69
|
@filename = @options[:filename]
|
69
70
|
@open = true
|
data/lib/mongo/index.rb
CHANGED
data/lib/mongo/index/view.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -51,6 +51,7 @@ module Mongo
|
|
51
51
|
:bucket_size => :bucketSize,
|
52
52
|
:default_language => :default_language,
|
53
53
|
:expire_after => :expireAfterSeconds,
|
54
|
+
:expire_after_seconds => :expireAfterSeconds,
|
54
55
|
:key => :key,
|
55
56
|
:language_override => :language_override,
|
56
57
|
:max => :max,
|
@@ -150,7 +151,7 @@ module Mongo
|
|
150
151
|
indexes: normalize_models(models.flatten),
|
151
152
|
db_name: database.name,
|
152
153
|
coll_name: collection.name,
|
153
|
-
).execute(next_primary
|
154
|
+
).execute(next_primary)
|
154
155
|
end
|
155
156
|
|
156
157
|
# Convenience method for getting index information by a specific name or
|
@@ -216,7 +217,7 @@ module Mongo
|
|
216
217
|
db_name: database.name,
|
217
218
|
coll_name: collection.name,
|
218
219
|
index_name: name
|
219
|
-
).execute(next_primary
|
220
|
+
).execute(next_primary)
|
220
221
|
end
|
221
222
|
|
222
223
|
def index_name(spec)
|
@@ -249,7 +250,7 @@ module Mongo
|
|
249
250
|
end
|
250
251
|
|
251
252
|
def send_initial_query(server)
|
252
|
-
initial_query_op.execute(server
|
253
|
+
initial_query_op.execute(server)
|
253
254
|
end
|
254
255
|
|
255
256
|
def with_generated_names(models)
|
data/lib/mongo/loggable.rb
CHANGED
data/lib/mongo/logger.rb
CHANGED
data/lib/mongo/monitoring.rb
CHANGED
data/lib/mongo/operation.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -43,17 +43,17 @@ module Mongo
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def filter_selector(
|
47
|
-
return selector if
|
46
|
+
def filter_selector(server)
|
47
|
+
return selector if server.features.write_command_enabled?
|
48
48
|
selector.reject{ |option, value| option.to_s == 'cursor' }
|
49
49
|
end
|
50
50
|
|
51
|
-
def update_selector(
|
52
|
-
if
|
53
|
-
sel = selector[:$query] ? filter_selector(
|
51
|
+
def update_selector(server)
|
52
|
+
if server.mongos? && read_pref = read.to_mongos
|
53
|
+
sel = selector[:$query] ? filter_selector(server) : { :$query => filter_selector(server) }
|
54
54
|
sel.merge(:$readPreference => read_pref)
|
55
55
|
else
|
56
|
-
filter_selector(
|
56
|
+
filter_selector(server)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -37,20 +37,21 @@ module Mongo
|
|
37
37
|
include Executable
|
38
38
|
|
39
39
|
# Execute the operation.
|
40
|
-
# The context gets a connection on which the operation
|
41
|
-
# is sent in the block.
|
42
40
|
#
|
43
|
-
# @
|
41
|
+
# @example Execute the operation.
|
42
|
+
# operation.execute(server)
|
43
|
+
#
|
44
|
+
# @param [ Mongo::Server ] server The server to send this operation to.
|
44
45
|
#
|
45
46
|
# @return [ Result ] The operation response, if there is one.
|
46
47
|
#
|
47
48
|
# @since 2.0.0
|
48
|
-
def execute(
|
49
|
-
if
|
50
|
-
ListCollections.new(spec).execute(
|
49
|
+
def execute(server)
|
50
|
+
if server.features.list_collections_enabled?
|
51
|
+
ListCollections.new(spec).execute(server)
|
51
52
|
else
|
52
|
-
|
53
|
-
Result.new(connection.dispatch([ message(
|
53
|
+
server.with_connection do |connection|
|
54
|
+
Result.new(connection.dispatch([ message(server) ])).validate!
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -35,27 +35,28 @@ module Mongo
|
|
35
35
|
include ReadPreference
|
36
36
|
|
37
37
|
# Execute the operation.
|
38
|
-
# The context gets a connection on which the operation
|
39
|
-
# is sent in the block.
|
40
38
|
#
|
41
|
-
# @
|
39
|
+
# @example Execute the operation.
|
40
|
+
# operation.execute(server)
|
41
|
+
#
|
42
|
+
# @param [ Mongo::Server ] server The server to send this operation to.
|
42
43
|
#
|
43
44
|
# @return [ Result ] The indexes operation response.
|
44
45
|
#
|
45
46
|
# @since 2.0.0
|
46
|
-
def execute(
|
47
|
-
if
|
48
|
-
ListIndexes.new(spec).execute(
|
47
|
+
def execute(server)
|
48
|
+
if server.features.list_indexes_enabled?
|
49
|
+
ListIndexes.new(spec).execute(server)
|
49
50
|
else
|
50
|
-
execute_message(
|
51
|
+
execute_message(server)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
55
|
private
|
55
56
|
|
56
|
-
def execute_message(
|
57
|
-
|
58
|
-
Result.new(connection.dispatch([ message(
|
57
|
+
def execute_message(server)
|
58
|
+
server.with_connection do |connection|
|
59
|
+
Result.new(connection.dispatch([ message(server) ]))
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -34,20 +34,21 @@ module Mongo
|
|
34
34
|
include Specifiable
|
35
35
|
|
36
36
|
# Execute the operation.
|
37
|
-
# The context gets a connection on which the operation
|
38
|
-
# is sent in the block.
|
39
37
|
#
|
40
|
-
# @
|
38
|
+
# @example Execute the operation.
|
39
|
+
# operation.execute(server)
|
40
|
+
#
|
41
|
+
# @param [ Mongo::Server ] server The server to send this operation to.
|
41
42
|
#
|
42
43
|
# @return [ Result ] The operation response, if there is one.
|
43
44
|
#
|
44
45
|
# @since 2.1.0
|
45
|
-
def execute(
|
46
|
-
if
|
47
|
-
UsersInfo.new(spec).execute(
|
46
|
+
def execute(server)
|
47
|
+
if server.features.users_info_enabled?
|
48
|
+
UsersInfo.new(spec).execute(server).validate!
|
48
49
|
else
|
49
|
-
|
50
|
-
Result.new(connection.dispatch([ message(
|
50
|
+
server.with_connection do |connection|
|
51
|
+
Result.new(connection.dispatch([ message(server) ])).validate!
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -62,7 +63,7 @@ module Mongo
|
|
62
63
|
Auth::User::COLLECTION
|
63
64
|
end
|
64
65
|
|
65
|
-
def message(
|
66
|
+
def message(server)
|
66
67
|
Protocol::Query.new(db_name, query_coll, selector, options)
|
67
68
|
end
|
68
69
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -37,7 +37,7 @@ module Mongo
|
|
37
37
|
{ :usersInfo => user_name }
|
38
38
|
end
|
39
39
|
|
40
|
-
def message(
|
40
|
+
def message(server)
|
41
41
|
Protocol::Query.new(db_name, query_coll, selector, options)
|
42
42
|
end
|
43
43
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2016 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.
|
@@ -22,18 +22,19 @@ module Mongo
|
|
22
22
|
module Executable
|
23
23
|
|
24
24
|
# Execute the operation.
|
25
|
-
# The context gets a connection on which the operation
|
26
|
-
# is sent in the block.
|
27
25
|
#
|
28
|
-
# @
|
26
|
+
# @example Execute the operation.
|
27
|
+
# operation.execute(server)
|
28
|
+
#
|
29
|
+
# @param [ Mongo::Server ] server The server to send this operation to.
|
29
30
|
#
|
30
31
|
# @return [ Result ] The operation response, if there is one.
|
31
32
|
#
|
32
33
|
# @since 2.0.0
|
33
|
-
def execute(
|
34
|
-
|
34
|
+
def execute(server)
|
35
|
+
server.with_connection do |connection|
|
35
36
|
result_class = self.class.const_defined?(:Result, false) ? self.class::Result : Result
|
36
|
-
result_class.new(connection.dispatch([ message(
|
37
|
+
result_class.new(connection.dispatch([ message(server) ], operation_id)).validate!
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|