mongo 2.2.7 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/lib/mongo.rb +1 -1
  8. data/lib/mongo/address.rb +1 -1
  9. data/lib/mongo/address/ipv4.rb +1 -1
  10. data/lib/mongo/address/ipv6.rb +1 -1
  11. data/lib/mongo/address/unix.rb +1 -1
  12. data/lib/mongo/auth.rb +1 -1
  13. data/lib/mongo/auth/cr.rb +1 -1
  14. data/lib/mongo/auth/ldap.rb +1 -1
  15. data/lib/mongo/auth/roles.rb +1 -1
  16. data/lib/mongo/auth/user.rb +1 -1
  17. data/lib/mongo/auth/user/view.rb +5 -5
  18. data/lib/mongo/auth/x509.rb +1 -1
  19. data/lib/mongo/bson.rb +1 -1
  20. data/lib/mongo/bulk_write.rb +4 -4
  21. data/lib/mongo/bulk_write/combineable.rb +1 -1
  22. data/lib/mongo/bulk_write/ordered_combiner.rb +1 -1
  23. data/lib/mongo/bulk_write/result.rb +1 -1
  24. data/lib/mongo/bulk_write/result_combiner.rb +1 -1
  25. data/lib/mongo/bulk_write/transformable.rb +1 -1
  26. data/lib/mongo/bulk_write/unordered_combiner.rb +1 -1
  27. data/lib/mongo/bulk_write/validatable.rb +1 -1
  28. data/lib/mongo/client.rb +2 -2
  29. data/lib/mongo/cluster.rb +15 -3
  30. data/lib/mongo/cluster/cursor_reaper.rb +174 -0
  31. data/lib/mongo/cluster/topology.rb +1 -1
  32. data/lib/mongo/cluster/topology/replica_set.rb +1 -1
  33. data/lib/mongo/cluster/topology/sharded.rb +1 -1
  34. data/lib/mongo/cluster/topology/single.rb +1 -1
  35. data/lib/mongo/cluster/topology/unknown.rb +1 -1
  36. data/lib/mongo/collection.rb +5 -4
  37. data/lib/mongo/collection/view.rb +4 -4
  38. data/lib/mongo/collection/view/aggregation.rb +2 -2
  39. data/lib/mongo/collection/view/builder.rb +1 -1
  40. data/lib/mongo/collection/view/builder/aggregation.rb +1 -1
  41. data/lib/mongo/collection/view/builder/find_command.rb +1 -1
  42. data/lib/mongo/collection/view/builder/flags.rb +1 -1
  43. data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
  44. data/lib/mongo/collection/view/builder/modifiers.rb +1 -1
  45. data/lib/mongo/collection/view/builder/op_query.rb +1 -1
  46. data/lib/mongo/collection/view/explainable.rb +1 -1
  47. data/lib/mongo/collection/view/immutable.rb +1 -1
  48. data/lib/mongo/collection/view/iterable.rb +2 -2
  49. data/lib/mongo/collection/view/map_reduce.rb +3 -3
  50. data/lib/mongo/collection/view/readable.rb +23 -6
  51. data/lib/mongo/collection/view/writable.rb +3 -3
  52. data/lib/mongo/cursor.rb +50 -7
  53. data/lib/mongo/cursor/builder.rb +1 -1
  54. data/lib/mongo/cursor/builder/get_more_command.rb +1 -1
  55. data/lib/mongo/cursor/builder/kill_cursors_command.rb +29 -1
  56. data/lib/mongo/cursor/builder/op_get_more.rb +1 -1
  57. data/lib/mongo/cursor/builder/op_kill_cursors.rb +29 -1
  58. data/lib/mongo/database.rb +4 -4
  59. data/lib/mongo/database/view.rb +2 -2
  60. data/lib/mongo/dbref.rb +4 -3
  61. data/lib/mongo/error.rb +1 -1
  62. data/lib/mongo/error/bulk_write_error.rb +1 -1
  63. data/lib/mongo/error/closed_stream.rb +1 -1
  64. data/lib/mongo/error/extra_file_chunk.rb +1 -1
  65. data/lib/mongo/error/file_not_found.rb +1 -1
  66. data/lib/mongo/error/invalid_bulk_operation.rb +1 -1
  67. data/lib/mongo/error/invalid_bulk_operation_type.rb +1 -1
  68. data/lib/mongo/error/invalid_collection_name.rb +1 -1
  69. data/lib/mongo/error/invalid_database_name.rb +1 -1
  70. data/lib/mongo/error/invalid_document.rb +1 -1
  71. data/lib/mongo/error/invalid_file.rb +1 -1
  72. data/lib/mongo/error/invalid_file_revision.rb +1 -1
  73. data/lib/mongo/error/invalid_nonce.rb +1 -1
  74. data/lib/mongo/error/invalid_replacement_document.rb +1 -1
  75. data/lib/mongo/error/invalid_server_preference.rb +1 -1
  76. data/lib/mongo/error/invalid_signature.rb +1 -1
  77. data/lib/mongo/error/invalid_update_document.rb +1 -1
  78. data/lib/mongo/error/invalid_uri.rb +1 -1
  79. data/lib/mongo/error/invalid_write_concern.rb +1 -1
  80. data/lib/mongo/error/max_bson_size.rb +1 -1
  81. data/lib/mongo/error/max_message_size.rb +1 -1
  82. data/lib/mongo/error/missing_file_chunk.rb +1 -1
  83. data/lib/mongo/error/multi_index_drop.rb +1 -1
  84. data/lib/mongo/error/need_primary_server.rb +1 -1
  85. data/lib/mongo/error/no_server_available.rb +4 -2
  86. data/lib/mongo/error/operation_failure.rb +1 -1
  87. data/lib/mongo/error/parser.rb +1 -1
  88. data/lib/mongo/error/socket_error.rb +1 -1
  89. data/lib/mongo/error/socket_timeout_error.rb +1 -1
  90. data/lib/mongo/error/unchangeable_collection_option.rb +1 -1
  91. data/lib/mongo/error/unexpected_chunk_length.rb +1 -1
  92. data/lib/mongo/error/unexpected_response.rb +1 -1
  93. data/lib/mongo/error/unsupported_features.rb +1 -1
  94. data/lib/mongo/event.rb +1 -1
  95. data/lib/mongo/event/description_changed.rb +1 -1
  96. data/lib/mongo/event/publisher.rb +1 -1
  97. data/lib/mongo/event/subscriber.rb +1 -1
  98. data/lib/mongo/grid.rb +1 -1
  99. data/lib/mongo/grid/file.rb +6 -2
  100. data/lib/mongo/grid/file/chunk.rb +6 -4
  101. data/lib/mongo/grid/file/info.rb +7 -3
  102. data/lib/mongo/grid/fs_bucket.rb +12 -6
  103. data/lib/mongo/grid/stream.rb +1 -1
  104. data/lib/mongo/grid/stream/read.rb +2 -4
  105. data/lib/mongo/grid/stream/write.rb +4 -3
  106. data/lib/mongo/index.rb +1 -1
  107. data/lib/mongo/index/view.rb +5 -4
  108. data/lib/mongo/loggable.rb +1 -1
  109. data/lib/mongo/logger.rb +1 -1
  110. data/lib/mongo/monitoring.rb +1 -1
  111. data/lib/mongo/operation.rb +1 -1
  112. data/lib/mongo/operation/commands.rb +1 -1
  113. data/lib/mongo/operation/commands/aggregate.rb +7 -7
  114. data/lib/mongo/operation/commands/aggregate/result.rb +1 -1
  115. data/lib/mongo/operation/commands/collections_info.rb +10 -9
  116. data/lib/mongo/operation/commands/collections_info/result.rb +1 -1
  117. data/lib/mongo/operation/commands/command.rb +1 -1
  118. data/lib/mongo/operation/commands/indexes.rb +12 -11
  119. data/lib/mongo/operation/commands/list_collections.rb +1 -1
  120. data/lib/mongo/operation/commands/list_collections/result.rb +1 -1
  121. data/lib/mongo/operation/commands/list_indexes.rb +1 -1
  122. data/lib/mongo/operation/commands/list_indexes/result.rb +1 -1
  123. data/lib/mongo/operation/commands/map_reduce.rb +1 -1
  124. data/lib/mongo/operation/commands/map_reduce/result.rb +1 -1
  125. data/lib/mongo/operation/commands/user_query.rb +11 -10
  126. data/lib/mongo/operation/commands/users_info.rb +2 -2
  127. data/lib/mongo/operation/commands/users_info/result.rb +1 -1
  128. data/lib/mongo/operation/executable.rb +8 -7
  129. data/lib/mongo/operation/kill_cursors.rb +2 -2
  130. data/lib/mongo/operation/limited.rb +1 -1
  131. data/lib/mongo/operation/read.rb +1 -1
  132. data/lib/mongo/operation/read/get_more.rb +2 -2
  133. data/lib/mongo/operation/read/query.rb +1 -1
  134. data/lib/mongo/operation/read/query/result.rb +1 -1
  135. data/lib/mongo/operation/read_preference.rb +10 -10
  136. data/lib/mongo/operation/result.rb +1 -1
  137. data/lib/mongo/operation/specifiable.rb +2 -2
  138. data/lib/mongo/operation/write.rb +1 -1
  139. data/lib/mongo/operation/write/bulk.rb +1 -1
  140. data/lib/mongo/operation/write/bulk/bulkable.rb +9 -9
  141. data/lib/mongo/operation/write/bulk/delete.rb +3 -3
  142. data/lib/mongo/operation/write/bulk/delete/result.rb +1 -1
  143. data/lib/mongo/operation/write/bulk/insert.rb +5 -5
  144. data/lib/mongo/operation/write/bulk/insert/result.rb +1 -1
  145. data/lib/mongo/operation/write/bulk/legacy_mergable.rb +1 -1
  146. data/lib/mongo/operation/write/bulk/mergable.rb +1 -1
  147. data/lib/mongo/operation/write/bulk/update.rb +3 -3
  148. data/lib/mongo/operation/write/bulk/update/result.rb +1 -1
  149. data/lib/mongo/operation/write/command.rb +1 -1
  150. data/lib/mongo/operation/write/command/create_index.rb +1 -1
  151. data/lib/mongo/operation/write/command/create_user.rb +1 -1
  152. data/lib/mongo/operation/write/command/delete.rb +1 -1
  153. data/lib/mongo/operation/write/command/drop_index.rb +1 -1
  154. data/lib/mongo/operation/write/command/insert.rb +11 -1
  155. data/lib/mongo/operation/write/command/remove_user.rb +1 -1
  156. data/lib/mongo/operation/write/command/update.rb +1 -1
  157. data/lib/mongo/operation/write/command/update_user.rb +1 -1
  158. data/lib/mongo/operation/write/command/writable.rb +7 -6
  159. data/lib/mongo/operation/write/create_index.rb +1 -1
  160. data/lib/mongo/operation/write/create_user.rb +1 -1
  161. data/lib/mongo/operation/write/delete.rb +1 -1
  162. data/lib/mongo/operation/write/delete/result.rb +1 -1
  163. data/lib/mongo/operation/write/drop_index.rb +5 -5
  164. data/lib/mongo/operation/write/gle.rb +3 -3
  165. data/lib/mongo/operation/write/idable.rb +1 -1
  166. data/lib/mongo/operation/write/insert.rb +5 -5
  167. data/lib/mongo/operation/write/insert/result.rb +1 -1
  168. data/lib/mongo/operation/write/remove_user.rb +1 -1
  169. data/lib/mongo/operation/write/update.rb +1 -1
  170. data/lib/mongo/operation/write/update/result.rb +1 -1
  171. data/lib/mongo/operation/write/update_user.rb +1 -1
  172. data/lib/mongo/operation/write/write_command_enabled.rb +10 -9
  173. data/lib/mongo/protocol/bit_vector.rb +2 -2
  174. data/lib/mongo/protocol/delete.rb +1 -1
  175. data/lib/mongo/protocol/get_more.rb +1 -1
  176. data/lib/mongo/protocol/insert.rb +5 -1
  177. data/lib/mongo/protocol/kill_cursors.rb +1 -1
  178. data/lib/mongo/protocol/message.rb +9 -5
  179. data/lib/mongo/protocol/query.rb +1 -1
  180. data/lib/mongo/protocol/reply.rb +1 -1
  181. data/lib/mongo/protocol/serializers.rb +8 -8
  182. data/lib/mongo/protocol/update.rb +1 -1
  183. data/lib/mongo/server.rb +40 -3
  184. data/lib/mongo/server/connectable.rb +1 -1
  185. data/lib/mongo/server/connection.rb +4 -2
  186. data/lib/mongo/server/connection_pool.rb +1 -1
  187. data/lib/mongo/server/connection_pool/queue.rb +1 -1
  188. data/lib/mongo/server/context.rb +3 -1
  189. data/lib/mongo/server/description.rb +1 -1
  190. data/lib/mongo/server/description/inspector/description_changed.rb +1 -1
  191. data/lib/mongo/server/monitor.rb +1 -1
  192. data/lib/mongo/server_selector.rb +2 -1
  193. data/lib/mongo/server_selector/nearest.rb +1 -1
  194. data/lib/mongo/server_selector/primary.rb +1 -1
  195. data/lib/mongo/server_selector/primary_preferred.rb +1 -1
  196. data/lib/mongo/server_selector/secondary.rb +1 -1
  197. data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
  198. data/lib/mongo/server_selector/selectable.rb +12 -7
  199. data/lib/mongo/socket.rb +1 -1
  200. data/lib/mongo/socket/ssl.rb +1 -1
  201. data/lib/mongo/socket/tcp.rb +1 -1
  202. data/lib/mongo/socket/unix.rb +1 -1
  203. data/lib/mongo/uri.rb +1 -1
  204. data/lib/mongo/version.rb +2 -2
  205. data/lib/mongo/write_concern/acknowledged.rb +1 -1
  206. data/lib/mongo/write_concern/normalizable.rb +1 -1
  207. data/lib/mongo/write_concern/unacknowledged.rb +1 -1
  208. data/mongo.gemspec +1 -1
  209. data/spec/mongo/client_spec.rb +2 -2
  210. data/spec/mongo/cluster/cursor_reaper_spec.rb +216 -0
  211. data/spec/mongo/cluster_spec.rb +36 -5
  212. data/spec/mongo/collection/view/aggregation_spec.rb +2 -2
  213. data/spec/mongo/collection/view/map_reduce_spec.rb +2 -2
  214. data/spec/mongo/collection/view/readable_spec.rb +203 -5
  215. data/spec/mongo/collection/view_spec.rb +10 -0
  216. data/spec/mongo/collection_spec.rb +64 -18
  217. data/spec/mongo/cursor_spec.rb +89 -0
  218. data/spec/mongo/database_spec.rb +79 -13
  219. data/spec/mongo/grid/fs_bucket_spec.rb +119 -1
  220. data/spec/mongo/grid/stream/write_spec.rb +63 -12
  221. data/spec/mongo/index/view_spec.rb +19 -0
  222. data/spec/mongo/operation/commands/aggregate_spec.rb +10 -7
  223. data/spec/mongo/operation/commands/collections_info_spec.rb +1 -1
  224. data/spec/mongo/operation/commands/command_spec.rb +3 -3
  225. data/spec/mongo/operation/commands/indexes_spec.rb +1 -1
  226. data/spec/mongo/operation/commands/map_reduce_spec.rb +2 -2
  227. data/spec/mongo/operation/kill_cursors_spec.rb +10 -19
  228. data/spec/mongo/operation/read/get_more_spec.rb +13 -25
  229. data/spec/mongo/operation/read/query_spec.rb +26 -30
  230. data/spec/mongo/operation/read_preference_spec.rb +11 -11
  231. data/spec/mongo/operation/specifiable_spec.rb +31 -0
  232. data/spec/mongo/operation/write/bulk/delete_spec.rb +16 -18
  233. data/spec/mongo/operation/write/bulk/insert_spec.rb +17 -18
  234. data/spec/mongo/operation/write/bulk/update_spec.rb +20 -25
  235. data/spec/mongo/operation/write/command/delete_spec.rb +26 -32
  236. data/spec/mongo/operation/write/command/insert_spec.rb +24 -31
  237. data/spec/mongo/operation/write/command/update_spec.rb +24 -32
  238. data/spec/mongo/operation/write/create_index_spec.rb +4 -4
  239. data/spec/mongo/operation/write/create_user_spec.rb +3 -3
  240. data/spec/mongo/operation/write/delete_spec.rb +51 -22
  241. data/spec/mongo/operation/write/drop_index_spec.rb +2 -2
  242. data/spec/mongo/operation/write/insert_spec.rb +42 -11
  243. data/spec/mongo/operation/write/remove_user_spec.rb +4 -4
  244. data/spec/mongo/operation/write/update_spec.rb +34 -6
  245. data/spec/mongo/operation/write/update_user_spec.rb +1 -1
  246. data/spec/mongo/server/connection_spec.rb +22 -14
  247. data/spec/mongo/server_selection_spec.rb +2 -2
  248. data/spec/mongo/server_selector/nearest_spec.rb +4 -4
  249. data/spec/mongo/server_selector/primary_preferred_spec.rb +4 -4
  250. data/spec/mongo/server_selector/primary_spec.rb +2 -2
  251. data/spec/mongo/server_selector/secondary_preferred_spec.rb +4 -4
  252. data/spec/mongo/server_selector/secondary_spec.rb +3 -3
  253. data/spec/mongo/server_selector_spec.rb +82 -3
  254. data/spec/mongo/server_spec.rb +0 -20
  255. data/spec/support/command_monitoring.rb +1 -1
  256. data/spec/support/connection_string.rb +1 -1
  257. data/spec/support/crud.rb +1 -1
  258. data/spec/support/crud/read.rb +1 -1
  259. data/spec/support/crud/write.rb +1 -1
  260. data/spec/support/gridfs.rb +1 -1
  261. data/spec/support/shared/server_selector.rb +3 -3
  262. metadata +7 -10
  263. metadata.gz.sig +0 -0
  264. data/lib/csasl/csasl.bundle +0 -0
  265. data/spec/mongo/operation/write/response_spec.rb +0 -85
  266. data/spec/support/shared/operation.rb +0 -100
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -32,7 +32,7 @@ module Mongo
32
32
 
33
33
  private
34
34
 
35
- def message(context)
35
+ def message(server)
36
36
  Protocol::KillCursors.new(coll_name, db_name, cursor_ids)
37
37
  end
38
38
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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,7 +43,7 @@ module Mongo
43
43
 
44
44
  private
45
45
 
46
- def message(context)
46
+ def message(server)
47
47
  Protocol::GetMore.new(db_name, coll_name, to_return, cursor_id)
48
48
  end
49
49
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -28,8 +28,8 @@ module Mongo
28
28
 
29
29
  private
30
30
 
31
- def update_selector(context)
32
- if context.mongos? && read_pref = read.to_mongos
31
+ def update_selector(server)
32
+ if server.mongos? && read_pref = read.to_mongos
33
33
  sel = selector[:$query] ? selector : { :$query => selector }
34
34
  sel.merge(:$readPreference => read_pref)
35
35
  else
@@ -37,12 +37,12 @@ module Mongo
37
37
  end
38
38
  end
39
39
 
40
- def slave_ok?(context)
41
- (context.cluster.single? && !context.mongos?) || read.slave_ok?
40
+ def slave_ok?(server)
41
+ (server.cluster.single? && !server.mongos?) || read.slave_ok?
42
42
  end
43
43
 
44
- def update_options(context)
45
- if slave_ok?(context)
44
+ def update_options(server)
45
+ if slave_ok?(server)
46
46
  options.dup.tap do |opts|
47
47
  (opts[:flags] ||= []) << SLAVE_OK
48
48
  end
@@ -51,9 +51,9 @@ module Mongo
51
51
  end
52
52
  end
53
53
 
54
- def message(context)
55
- sel = update_selector(context)
56
- opts = update_options(context)
54
+ def message(server)
55
+ sel = update_selector(server)
56
+ opts = update_options(server)
57
57
  Protocol::Query.new(db_name, query_coll, sel, opts)
58
58
  end
59
59
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -442,7 +442,7 @@ module Mongo
442
442
  #
443
443
  # @since 2.0.0
444
444
  def read
445
- @spec[READ] || ServerSelector.get
445
+ @read ||= ServerSelector.get(@spec[READ] || ServerSelector::PRIMARY)
446
446
  end
447
447
 
448
448
  # Whether the operation is ordered.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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,26 +27,26 @@ module Mongo
27
27
  # Execute the bulk operation.
28
28
  #
29
29
  # @example Execute the operation.
30
- # operation.execute(context)
30
+ # operation.execute(server)
31
31
  #
32
- # @param [ Mongo::Server::Context ] context The context for this operation.
32
+ # @param [ Mongo::Server ] server The server to send this operation to.
33
33
  #
34
34
  # @return [ Result ] The operation result.
35
35
  #
36
36
  # @since 2.0.0
37
- def execute(context)
38
- if context.features.write_command_enabled?
39
- execute_write_command(context)
37
+ def execute(server)
38
+ if server.features.write_command_enabled?
39
+ execute_write_command(server)
40
40
  else
41
- execute_message(context)
41
+ execute_message(server)
42
42
  end
43
43
  end
44
44
 
45
45
  private
46
46
 
47
- def execute_message(context)
47
+ def execute_message(server)
48
48
  replies = messages.map do |m|
49
- context.with_connection do |connection|
49
+ server.with_connection do |connection|
50
50
  result = self.class::LegacyResult.new(connection.dispatch([ m, gle ].compact, operation_id))
51
51
  if stop_sending?(result)
52
52
  return result
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -54,8 +54,8 @@ module Mongo
54
54
 
55
55
  private
56
56
 
57
- def execute_write_command(context)
58
- Result.new(Command::Delete.new(spec).execute(context))
57
+ def execute_write_command(server)
58
+ Result.new(Command::Delete.new(spec).execute(server))
59
59
  end
60
60
 
61
61
  def messages
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -54,15 +54,15 @@ module Mongo
54
54
 
55
55
  private
56
56
 
57
- def execute_write_command(context)
57
+ def execute_write_command(server)
58
58
  command_spec = spec.merge(:documents => ensure_ids(documents))
59
- Result.new(Command::Insert.new(command_spec).execute(context), @ids)
59
+ Result.new(Command::Insert.new(command_spec).execute(server), @ids)
60
60
  end
61
61
 
62
- def execute_message(context)
62
+ def execute_message(server)
63
63
  replies = []
64
64
  messages.map do |m|
65
- context.with_connection do |connection|
65
+ server.with_connection do |connection|
66
66
  result = LegacyResult.new(connection.dispatch([ m, gle ].compact, operation_id), @ids)
67
67
  replies << result.reply
68
68
  if stop_sending?(result)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -61,8 +61,8 @@ module Mongo
61
61
 
62
62
  private
63
63
 
64
- def execute_write_command(context)
65
- Result.new(Command::Update.new(spec).execute(context))
64
+ def execute_write_command(server)
65
+ Result.new(Command::Update.new(spec).execute(server))
66
66
  end
67
67
 
68
68
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,5 +1,5 @@
1
1
 
2
- # Copyright (C) 2014-2015 MongoDB, Inc.
2
+ # Copyright (C) 2014-2016 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -48,6 +48,16 @@ module Mongo
48
48
  cmd.merge!(:bypassDocumentValidation => true) if bypass_document_validation
49
49
  end
50
50
  end
51
+
52
+ # The wire protocol message for this write operation.
53
+ #
54
+ # @return [ Mongo::Protocol::Query ] Wire protocol message.
55
+ #
56
+ # @since 2.2.5
57
+ def message
58
+ opts = options.merge(validating_keys: true)
59
+ Protocol::Query.new(db_name, Database::COMMAND, selector, opts)
60
+ end
51
61
  end
52
62
  end
53
63
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,5 +1,5 @@
1
1
 
2
- # Copyright (C) 2014-2015 MongoDB, Inc.
2
+ # Copyright (C) 2014-2016 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -25,16 +25,17 @@ module Mongo
25
25
  include Limited
26
26
 
27
27
  # Execute the operation.
28
- # The context gets a connection on which the operation
29
- # is sent in the block.
30
28
  #
31
- # @param [ Mongo::Server::Context ] context The context for this operation.
29
+ # @example Execute the operation.
30
+ # operation.execute(server)
31
+ #
32
+ # @param [ Mongo::Server ] server The server to send this operation to.
32
33
  #
33
34
  # @return [ Result ] The operation response, if there is one.
34
35
  #
35
36
  # @since 2.0.0
36
- def execute(context)
37
- context.with_connection do |connection|
37
+ def execute(server)
38
+ server.with_connection do |connection|
38
39
  connection.dispatch([ message ], operation_id)
39
40
  end
40
41
  end
@@ -1,5 +1,5 @@
1
1
 
2
- # Copyright (C) 2014-2015 MongoDB, Inc.
2
+ # Copyright (C) 2014-2016 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.
@@ -1,5 +1,5 @@
1
1
 
2
- # Copyright (C) 2014-2015 MongoDB, Inc.
2
+ # Copyright (C) 2014-2016 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -41,15 +41,15 @@ module Mongo
41
41
  # Execute the drop index operation.
42
42
  #
43
43
  # @example Execute the operation.
44
- # operation.execute(context)
44
+ # operation.execute(server)
45
45
  #
46
- # @param [ Mongo::Server::Context ] context The context for this operation.
46
+ # @param [ Mongo::Server ] server The server to send this operation to.
47
47
  #
48
48
  # @return [ Result ] The result of the operation.
49
49
  #
50
50
  # @since 2.0.0
51
- def execute(context)
52
- execute_write_command(context)
51
+ def execute(server)
52
+ execute_write_command(server)
53
53
  end
54
54
 
55
55
  private
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 MongoDB, Inc.
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.
@@ -24,8 +24,8 @@ module Mongo
24
24
 
25
25
  private
26
26
 
27
- def execute_message(context)
28
- context.with_connection do |connection|
27
+ def execute_message(server)
28
+ server.with_connection do |connection|
29
29
  result_class = self.class.const_defined?(:LegacyResult, false) ? self.class::LegacyResult :
30
30
  self.class.const_defined?(:Result, false) ? self.class::Result : Result
31
31
  result_class.new(connection.dispatch([ message, gle ].compact)).validate!