mongo 2.13.1 → 2.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -4
  4. data/lib/mongo.rb +9 -0
  5. data/lib/mongo/address/ipv4.rb +1 -1
  6. data/lib/mongo/address/ipv6.rb +1 -1
  7. data/lib/mongo/bulk_write.rb +17 -0
  8. data/lib/mongo/caching_cursor.rb +74 -0
  9. data/lib/mongo/client.rb +47 -8
  10. data/lib/mongo/cluster.rb +3 -3
  11. data/lib/mongo/cluster/topology/single.rb +1 -1
  12. data/lib/mongo/collection.rb +26 -0
  13. data/lib/mongo/collection/view.rb +24 -20
  14. data/lib/mongo/collection/view/aggregation.rb +25 -4
  15. data/lib/mongo/collection/view/builder/find_command.rb +38 -18
  16. data/lib/mongo/collection/view/explainable.rb +27 -8
  17. data/lib/mongo/collection/view/iterable.rb +72 -12
  18. data/lib/mongo/collection/view/readable.rb +12 -2
  19. data/lib/mongo/collection/view/writable.rb +15 -1
  20. data/lib/mongo/crypt/encryption_io.rb +6 -6
  21. data/lib/mongo/cursor.rb +1 -0
  22. data/lib/mongo/database.rb +6 -0
  23. data/lib/mongo/error.rb +2 -0
  24. data/lib/mongo/error/invalid_read_concern.rb +28 -0
  25. data/lib/mongo/error/server_certificate_revoked.rb +22 -0
  26. data/lib/mongo/error/unsupported_option.rb +14 -12
  27. data/lib/mongo/lint.rb +2 -1
  28. data/lib/mongo/logger.rb +3 -3
  29. data/lib/mongo/operation.rb +2 -0
  30. data/lib/mongo/operation/aggregate/result.rb +9 -8
  31. data/lib/mongo/operation/collections_info/result.rb +2 -0
  32. data/lib/mongo/operation/delete/bulk_result.rb +2 -0
  33. data/lib/mongo/operation/delete/result.rb +3 -0
  34. data/lib/mongo/operation/explain/command.rb +4 -0
  35. data/lib/mongo/operation/explain/legacy.rb +4 -0
  36. data/lib/mongo/operation/explain/op_msg.rb +6 -0
  37. data/lib/mongo/operation/explain/result.rb +3 -0
  38. data/lib/mongo/operation/find/legacy/result.rb +2 -0
  39. data/lib/mongo/operation/find/result.rb +3 -0
  40. data/lib/mongo/operation/get_more/result.rb +3 -0
  41. data/lib/mongo/operation/indexes/result.rb +5 -0
  42. data/lib/mongo/operation/insert/bulk_result.rb +5 -0
  43. data/lib/mongo/operation/insert/result.rb +5 -0
  44. data/lib/mongo/operation/list_collections/result.rb +5 -0
  45. data/lib/mongo/operation/map_reduce/result.rb +10 -0
  46. data/lib/mongo/operation/parallel_scan/result.rb +4 -0
  47. data/lib/mongo/operation/result.rb +35 -6
  48. data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
  49. data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
  50. data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
  51. data/lib/mongo/operation/shared/executable.rb +1 -0
  52. data/lib/mongo/operation/shared/idable.rb +2 -1
  53. data/lib/mongo/operation/shared/limited.rb +1 -0
  54. data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
  55. data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
  56. data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
  57. data/lib/mongo/operation/shared/specifiable.rb +1 -0
  58. data/lib/mongo/operation/shared/write.rb +1 -0
  59. data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
  60. data/lib/mongo/operation/update/legacy/result.rb +7 -0
  61. data/lib/mongo/operation/update/result.rb +8 -0
  62. data/lib/mongo/operation/users_info/result.rb +3 -0
  63. data/lib/mongo/query_cache.rb +242 -0
  64. data/lib/mongo/retryable.rb +8 -1
  65. data/lib/mongo/server.rb +5 -1
  66. data/lib/mongo/server/connection_common.rb +2 -2
  67. data/lib/mongo/server/connection_pool.rb +3 -0
  68. data/lib/mongo/server/monitor.rb +1 -1
  69. data/lib/mongo/server/monitor/connection.rb +3 -3
  70. data/lib/mongo/server/pending_connection.rb +2 -2
  71. data/lib/mongo/server/push_monitor.rb +1 -1
  72. data/lib/mongo/server_selector/base.rb +5 -1
  73. data/lib/mongo/session.rb +3 -0
  74. data/lib/mongo/socket.rb +6 -4
  75. data/lib/mongo/socket/ocsp_cache.rb +97 -0
  76. data/lib/mongo/socket/ocsp_verifier.rb +368 -0
  77. data/lib/mongo/socket/ssl.rb +45 -24
  78. data/lib/mongo/srv/monitor.rb +7 -13
  79. data/lib/mongo/srv/resolver.rb +14 -10
  80. data/lib/mongo/timeout.rb +2 -0
  81. data/lib/mongo/uri.rb +21 -390
  82. data/lib/mongo/uri/options_mapper.rb +582 -0
  83. data/lib/mongo/uri/srv_protocol.rb +3 -2
  84. data/lib/mongo/utils.rb +12 -1
  85. data/lib/mongo/version.rb +1 -1
  86. data/spec/NOTES.aws-auth.md +12 -7
  87. data/spec/README.md +56 -1
  88. data/spec/integration/bulk_write_spec.rb +48 -0
  89. data/spec/integration/client_authentication_options_spec.rb +55 -28
  90. data/spec/integration/connection_pool_populator_spec.rb +3 -1
  91. data/spec/integration/cursor_reaping_spec.rb +53 -17
  92. data/spec/integration/ocsp_connectivity_spec.rb +26 -0
  93. data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
  94. data/spec/integration/ocsp_verifier_spec.rb +334 -0
  95. data/spec/integration/query_cache_spec.rb +1045 -0
  96. data/spec/integration/query_cache_transactions_spec.rb +179 -0
  97. data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
  98. data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -0
  99. data/spec/integration/sdam_error_handling_spec.rb +68 -0
  100. data/spec/integration/server_selection_spec.rb +36 -0
  101. data/spec/integration/srv_monitoring_spec.rb +38 -3
  102. data/spec/integration/srv_spec.rb +56 -0
  103. data/spec/lite_spec_helper.rb +3 -1
  104. data/spec/mongo/address_spec.rb +1 -1
  105. data/spec/mongo/caching_cursor_spec.rb +70 -0
  106. data/spec/mongo/client_construction_spec.rb +54 -1
  107. data/spec/mongo/client_spec.rb +40 -0
  108. data/spec/mongo/cluster/topology/single_spec.rb +14 -5
  109. data/spec/mongo/cluster_spec.rb +3 -0
  110. data/spec/mongo/collection/view/explainable_spec.rb +87 -4
  111. data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
  112. data/spec/mongo/collection_spec.rb +60 -0
  113. data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
  114. data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
  115. data/spec/mongo/crypt/explicit_decryption_context_spec.rb +1 -1
  116. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
  117. data/spec/mongo/database_spec.rb +44 -0
  118. data/spec/mongo/error/no_server_available_spec.rb +1 -1
  119. data/spec/mongo/logger_spec.rb +13 -11
  120. data/spec/mongo/query_cache_spec.rb +279 -0
  121. data/spec/mongo/server/connection_pool_spec.rb +7 -3
  122. data/spec/mongo/server/connection_spec.rb +14 -7
  123. data/spec/mongo/socket/ssl_spec.rb +1 -1
  124. data/spec/mongo/socket_spec.rb +1 -1
  125. data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
  126. data/spec/mongo/uri_option_parsing_spec.rb +11 -11
  127. data/spec/mongo/uri_spec.rb +68 -41
  128. data/spec/mongo/utils_spec.rb +39 -0
  129. data/spec/runners/auth.rb +3 -0
  130. data/spec/runners/connection_string.rb +35 -124
  131. data/spec/spec_tests/cmap_spec.rb +7 -3
  132. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +0 -1
  133. data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
  134. data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
  135. data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
  136. data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
  137. data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
  138. data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
  139. data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
  140. data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
  141. data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
  142. data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
  143. data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
  144. data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
  145. data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
  146. data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
  147. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
  148. data/spec/spec_tests/uri_options_spec.rb +31 -33
  149. data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
  150. data/spec/support/certificates/atlas-ocsp.crt +41 -0
  151. data/spec/support/client_registry_macros.rb +11 -2
  152. data/spec/support/common_shortcuts.rb +45 -0
  153. data/spec/support/constraints.rb +23 -0
  154. data/spec/support/lite_constraints.rb +24 -0
  155. data/spec/support/matchers.rb +16 -0
  156. data/spec/support/ocsp +1 -0
  157. data/spec/support/session_registry.rb +52 -0
  158. data/spec/support/spec_config.rb +22 -0
  159. data/spec/support/utils.rb +19 -1
  160. metadata +38 -3
  161. metadata.gz.sig +0 -0
@@ -20,6 +20,7 @@ module Mongo
20
20
  # listIndexes command.
21
21
  #
22
22
  # @since 2.0.0
23
+ # @api semiprivate
23
24
  class Result < Operation::Result
24
25
 
25
26
  # Get the cursor id for the result.
@@ -35,6 +36,7 @@ module Mongo
35
36
  # @return [ Integer ] The cursor id.
36
37
  #
37
38
  # @since 2.0.0
39
+ # @api private
38
40
  def cursor_id
39
41
  cursor_document ? cursor_document[CURSOR_ID] : super
40
42
  end
@@ -47,6 +49,7 @@ module Mongo
47
49
  # @return [ String ] The namespace.
48
50
  #
49
51
  # @since 2.0.0
52
+ # @api private
50
53
  def namespace
51
54
  cursor_document ? cursor_document[NAMESPACE] : super
52
55
  end
@@ -60,6 +63,7 @@ module Mongo
60
63
  # @return [ Array<BSON::Document> ] The documents.
61
64
  #
62
65
  # @since 2.0.0
66
+ # @api public
63
67
  def documents
64
68
  cursor_document[FIRST_BATCH]
65
69
  end
@@ -77,6 +81,7 @@ module Mongo
77
81
  # @return [ Result ] Self if successful.
78
82
  #
79
83
  # @since 2.0.0
84
+ # @api private
80
85
  def validate!
81
86
  !successful? ? raise_operation_failure : self
82
87
  end
@@ -19,12 +19,14 @@ module Mongo
19
19
  # Defines custom behavior of results for an insert when sent as part of a bulk write.
20
20
  #
21
21
  # @since 2.0.0
22
+ # @api semiprivate
22
23
  class BulkResult < Operation::Result
23
24
  include Aggregatable
24
25
 
25
26
  # Get the ids of the inserted documents.
26
27
  #
27
28
  # @since 2.0.0
29
+ # @api public
28
30
  attr_reader :inserted_ids
29
31
 
30
32
  # Initialize a new result.
@@ -39,6 +41,7 @@ module Mongo
39
41
  # @param [ Array<Object> ] ids The ids of the inserted documents.
40
42
  #
41
43
  # @since 2.0.0
44
+ # @api private
42
45
  def initialize(replies, connection_description, ids)
43
46
  @replies = [*replies] if replies
44
47
  @connection_description = connection_description
@@ -83,6 +86,7 @@ module Mongo
83
86
  # @return [ Integer ] The number of documents inserted.
84
87
  #
85
88
  # @since 2.0.0
89
+ # @api public
86
90
  def n_inserted
87
91
  written_count
88
92
  end
@@ -95,6 +99,7 @@ module Mongo
95
99
  # @return [ Object ] The id of the document inserted.
96
100
  #
97
101
  # @since 2.0.0
102
+ # @api public
98
103
  def inserted_id
99
104
  inserted_ids.first
100
105
  end
@@ -22,11 +22,13 @@ module Mongo
22
22
  # is optional. It can be added to this class later, if needed.
23
23
  #
24
24
  # @since 2.0.0
25
+ # @api semiprivate
25
26
  class Result < Operation::Result
26
27
 
27
28
  # Get the ids of the inserted documents.
28
29
  #
29
30
  # @since 2.0.0
31
+ # @api public
30
32
  attr_reader :inserted_ids
31
33
 
32
34
  # Initialize a new result.
@@ -41,6 +43,7 @@ module Mongo
41
43
  # @param [ Array<Object> ] ids The ids of the inserted documents.
42
44
  #
43
45
  # @since 2.0.0
46
+ # @api private
44
47
  def initialize(replies, connection_description, ids)
45
48
  super(replies, connection_description)
46
49
  @inserted_ids = ids
@@ -54,10 +57,12 @@ module Mongo
54
57
  # @return [ Object ] The id of the document inserted.
55
58
  #
56
59
  # @since 2.0.0
60
+ # @api public
57
61
  def inserted_id
58
62
  inserted_ids.first
59
63
  end
60
64
 
65
+ # @api public
61
66
  def bulk_result
62
67
  BulkResult.new(@replies, connection_description, @inserted_ids)
63
68
  end
@@ -20,6 +20,7 @@ module Mongo
20
20
  # listCollections command.
21
21
  #
22
22
  # @since 2.0.0
23
+ # @api semiprivate
23
24
  class Result < Operation::Result
24
25
 
25
26
  # Get the cursor id for the result.
@@ -35,6 +36,7 @@ module Mongo
35
36
  # @return [ Integer ] The cursor id.
36
37
  #
37
38
  # @since 2.0.0
39
+ # @api private
38
40
  def cursor_id
39
41
  cursor_document ? cursor_document[CURSOR_ID] : super
40
42
  end
@@ -47,6 +49,7 @@ module Mongo
47
49
  # @return [ String ] The namespace.
48
50
  #
49
51
  # @since 2.0.0
52
+ # @api private
50
53
  def namespace
51
54
  cursor_document ? cursor_document[NAMESPACE] : super
52
55
  end
@@ -60,6 +63,7 @@ module Mongo
60
63
  # @return [ Array<BSON::Document> ] The documents.
61
64
  #
62
65
  # @since 2.0.0
66
+ # @api public
63
67
  def documents
64
68
  cursor_document[FIRST_BATCH]
65
69
  end
@@ -73,6 +77,7 @@ module Mongo
73
77
  # @return [ Result ] Self if successful.
74
78
  #
75
79
  # @since 2.0.0
80
+ # @api private
76
81
  def validate!
77
82
  if successful?
78
83
  self
@@ -19,21 +19,25 @@ module Mongo
19
19
  # Defines custom behavior of results for a map reduce operation.
20
20
  #
21
21
  # @since 2.0.0
22
+ # @api semiprivate
22
23
  class Result < Operation::Result
23
24
 
24
25
  # The counts field for the map/reduce.
25
26
  #
26
27
  # @since 2.0.0
28
+ # @api private
27
29
  COUNTS = 'counts'.freeze
28
30
 
29
31
  # The field name for a result without a cursor.
30
32
  #
31
33
  # @since 2.0.0
34
+ # @api private
32
35
  RESULTS = 'results'.freeze
33
36
 
34
37
  # The time the operation took constant.
35
38
  #
36
39
  # @since 2.0.0
40
+ # @api private
37
41
  TIME = 'timeMillis'.freeze
38
42
 
39
43
  # Gets the map/reduce counts from the reply.
@@ -44,6 +48,7 @@ module Mongo
44
48
  # @return [ Hash ] A hash of the result counts.
45
49
  #
46
50
  # @since 2.0.0
51
+ # @api public
47
52
  def counts
48
53
  reply.documents[0][COUNTS]
49
54
  end
@@ -56,6 +61,7 @@ module Mongo
56
61
  # @return [ Array<BSON::Document> ] The documents.
57
62
  #
58
63
  # @since 2.0.0
64
+ # @api public
59
65
  def documents
60
66
  reply.documents[0][RESULTS] || reply.documents[0][RESULT]
61
67
  end
@@ -72,6 +78,7 @@ module Mongo
72
78
  # @return [ true, false ] If the command was successful.
73
79
  #
74
80
  # @since 2.0.0
81
+ # @api public
75
82
  def successful?
76
83
  !documents.nil?
77
84
  end
@@ -84,6 +91,7 @@ module Mongo
84
91
  # @return [ Integer ] The executing time in milliseconds.
85
92
  #
86
93
  # @since 2.0.0
94
+ # @api public
87
95
  def time
88
96
  reply.documents[0][TIME]
89
97
  end
@@ -102,6 +110,7 @@ module Mongo
102
110
  # @return [ Result ] The result if verification passed.
103
111
  #
104
112
  # @since 2.0.0
113
+ # @api private
105
114
  def validate!
106
115
  documents.nil? ? raise_operation_failure : self
107
116
  end
@@ -114,6 +123,7 @@ module Mongo
114
123
  # @return [ Integer ] Always 0 because map reduce doesn't return a cursor.
115
124
  #
116
125
  # @since 2.5.0
126
+ # @api private
117
127
  def cursor_id
118
128
  0
119
129
  end
@@ -19,11 +19,13 @@ module Mongo
19
19
  # Defines custom behavior of results in a parallel scan.
20
20
  #
21
21
  # @since 2.0.0
22
+ # @api semiprivate
22
23
  class Result < Operation::Result
23
24
 
24
25
  # The name of the cursors field in the result.
25
26
  #
26
27
  # @since 2.0.0
28
+ # @api private
27
29
  CURSORS = 'cursors'.freeze
28
30
 
29
31
  # Get all the cursor ids from the result.
@@ -34,6 +36,7 @@ module Mongo
34
36
  # @return [ Array<Integer> ] The cursor ids.
35
37
  #
36
38
  # @since 2.0.0
39
+ # @api private
37
40
  def cursor_ids
38
41
  documents.map {|doc| doc[CURSOR][CURSOR_ID]}
39
42
  end
@@ -46,6 +49,7 @@ module Mongo
46
49
  # @return [ Array<BSON::Document> ] The documents.
47
50
  #
48
51
  # @since 2.0.0
52
+ # @api public
49
53
  def documents
50
54
  reply.documents[0][CURSORS]
51
55
  end
@@ -27,6 +27,7 @@ module Mongo
27
27
  # produce a reply (in which case it is assumed to have succeeded).
28
28
  #
29
29
  # @since 2.0.0
30
+ # @api semiprivate
30
31
  class Result
31
32
  extend Forwardable
32
33
  include Enumerable
@@ -34,41 +35,49 @@ module Mongo
34
35
  # The field name for the cursor document in an aggregation.
35
36
  #
36
37
  # @since 2.2.0
38
+ # @api private
37
39
  CURSOR = 'cursor'.freeze
38
40
 
39
41
  # The cursor id field in the cursor document.
40
42
  #
41
43
  # @since 2.2.0
44
+ # @api private
42
45
  CURSOR_ID = 'id'.freeze
43
46
 
44
47
  # The field name for the first batch of a cursor.
45
48
  #
46
49
  # @since 2.2.0
50
+ # @api private
47
51
  FIRST_BATCH = 'firstBatch'.freeze
48
52
 
49
53
  # The field name for the next batch of a cursor.
50
54
  #
51
55
  # @since 2.2.0
56
+ # @api private
52
57
  NEXT_BATCH = 'nextBatch'.freeze
53
58
 
54
59
  # The namespace field in the cursor document.
55
60
  #
56
61
  # @since 2.2.0
62
+ # @api private
57
63
  NAMESPACE = 'ns'.freeze
58
64
 
59
65
  # The number of documents updated in the write.
60
66
  #
61
67
  # @since 2.0.0
68
+ # @api private
62
69
  N = 'n'.freeze
63
70
 
64
71
  # The ok status field in the result.
65
72
  #
66
73
  # @since 2.0.0
74
+ # @api private
67
75
  OK = 'ok'.freeze
68
76
 
69
77
  # The result field constant.
70
78
  #
71
79
  # @since 2.2.0
80
+ # @api private
72
81
  RESULT = 'result'.freeze
73
82
 
74
83
  # Initialize a new result.
@@ -106,6 +115,8 @@ module Mongo
106
115
  end
107
116
 
108
117
  # @return [ Array<Protocol::Message> ] replies The wrapped wire protocol replies.
118
+ #
119
+ # @api private
109
120
  attr_reader :replies
110
121
 
111
122
  # @return [ Server::Description ] Server description of the server that
@@ -129,6 +140,7 @@ module Mongo
129
140
  # @return [ true, false ] If the result is acknowledged.
130
141
  #
131
142
  # @since 2.0.0
143
+ # @api public
132
144
  def acknowledged?
133
145
  !!@replies
134
146
  end
@@ -143,6 +155,7 @@ module Mongo
143
155
  # @return [ Integer ] The cursor id.
144
156
  #
145
157
  # @since 2.0.0
158
+ # @api private
146
159
  def cursor_id
147
160
  acknowledged? ? replies.last.cursor_id : 0
148
161
  end
@@ -153,6 +166,7 @@ module Mongo
153
166
  # @return [ Nil ]
154
167
  #
155
168
  # @since 2.0.0
169
+ # @api private
156
170
  def namespace
157
171
  nil
158
172
  end
@@ -165,6 +179,7 @@ module Mongo
165
179
  # @return [ Array<BSON::Document> ] The documents.
166
180
  #
167
181
  # @since 2.0.0
182
+ # @api public
168
183
  def documents
169
184
  if acknowledged?
170
185
  replies.flat_map(&:documents)
@@ -182,9 +197,10 @@ module Mongo
182
197
  #
183
198
  # @return [ Enumerator ] The enumerator.
184
199
  #
185
- # @since 2.0.0
186
- #
187
200
  # @yieldparam [ BSON::Document ] Each document in the result.
201
+ #
202
+ # @since 2.0.0
203
+ # @api public
188
204
  def each(&block)
189
205
  documents.each(&block)
190
206
  end
@@ -197,6 +213,7 @@ module Mongo
197
213
  # @return [ String ] The inspection.
198
214
  #
199
215
  # @since 2.0.0
216
+ # @api public
200
217
  def inspect
201
218
  "#<#{self.class.name}:0x#{object_id} documents=#{documents}>"
202
219
  end
@@ -209,6 +226,7 @@ module Mongo
209
226
  # @return [ Protocol::Message ] The first reply.
210
227
  #
211
228
  # @since 2.0.0
229
+ # @api private
212
230
  def reply
213
231
  if acknowledged?
214
232
  replies.first
@@ -225,6 +243,7 @@ module Mongo
225
243
  # @return [ Integer ] The number of documents returned.
226
244
  #
227
245
  # @since 2.0.0
246
+ # @api public
228
247
  def returned_count
229
248
  if acknowledged?
230
249
  reply.number_returned
@@ -245,6 +264,7 @@ module Mongo
245
264
  # @return [ true, false ] If the command was successful.
246
265
  #
247
266
  # @since 2.0.0
267
+ # @api public
248
268
  def successful?
249
269
  return true if !acknowledged?
250
270
  if first_document.has_key?(OK)
@@ -262,6 +282,7 @@ module Mongo
262
282
  # @return [ true, false ] If the command returned ok.
263
283
  #
264
284
  # @since 2.1.0
285
+ # @api public
265
286
  def ok?
266
287
  # first_document[OK] is a float, and the server can return
267
288
  # ok as a BSON int32, BSON int64 or a BSON double.
@@ -285,6 +306,7 @@ module Mongo
285
306
  # @return [ Result ] The result if verification passed.
286
307
  #
287
308
  # @since 2.0.0
309
+ # @api private
288
310
  def validate!
289
311
  !successful? ? raise_operation_failure : self
290
312
  end
@@ -317,12 +339,13 @@ module Mongo
317
339
  # error information in this result.
318
340
  #
319
341
  # @raise Error::OperationFailure
320
- def raise_operation_failure
342
+ private def raise_operation_failure
321
343
  raise error
322
344
  end
323
- private :raise_operation_failure
324
345
 
325
346
  # @return [ TopologyVersion | nil ] The topology version.
347
+ #
348
+ # @api private
326
349
  def topology_version
327
350
  unless defined?(@topology_version)
328
351
  @topology_version = first_document['topologyVersion'] &&
@@ -339,6 +362,7 @@ module Mongo
339
362
  # @return [ Integer ] The number of documents written.
340
363
  #
341
364
  # @since 2.0.0
365
+ # @api public
342
366
  def written_count
343
367
  if acknowledged?
344
368
  first_document[N] || 0
@@ -346,6 +370,8 @@ module Mongo
346
370
  0
347
371
  end
348
372
  end
373
+
374
+ # @api public
349
375
  alias :n :written_count
350
376
 
351
377
  # Get the operation time reported in the server response.
@@ -353,9 +379,10 @@ module Mongo
353
379
  # @example Get the operation time.
354
380
  # result.operation_time
355
381
  #
356
- # @return [ Object ] The operation time value.
382
+ # @return [ Object | nil ] The operation time value.
357
383
  #
358
384
  # @since 2.5.0
385
+ # @api public
359
386
  def operation_time
360
387
  first_document && first_document[OPERATION_TIME]
361
388
  end
@@ -365,13 +392,14 @@ module Mongo
365
392
  # @example Get the cluster time.
366
393
  # result.cluster_time
367
394
  #
368
- # @return [ nil | ClusterTime ] The cluster time document.
395
+ # @return [ ClusterTime | nil ] The cluster time document.
369
396
  #
370
397
  # Changed in version 2.9.0: This attribute became an instance of
371
398
  # ClusterTime, which is a subclass of BSON::Document.
372
399
  # Previously it was an instance of BSON::Document.
373
400
  #
374
401
  # @since 2.5.0
402
+ # @api public
375
403
  def cluster_time
376
404
  first_document && ClusterTime[first_document['$clusterTime']]
377
405
  end
@@ -384,6 +412,7 @@ module Mongo
384
412
  # @return [ Array ] labels The set of labels.
385
413
  #
386
414
  # @since 2.7.0
415
+ # @api private
387
416
  def labels
388
417
  @labels ||= parser.labels
389
418
  end