Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions lib/mongo/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,13 @@ def hash
# @option options [ Integer ] :max_pool_size The maximum size of the
# connection pool. Setting this option to zero creates an unlimited connection pool.
# @option options [ Integer ] :max_read_retries The maximum number of read
# retries when legacy read retries are in use.
# retries when legacy read retries are in use. Deprecated: this option
# only affects the legacy retry implementation, which is deprecated and
# will be removed in a future version.
# @option options [ Integer ] :max_write_retries The maximum number of write
# retries when legacy write retries are in use.
# retries when legacy write retries are in use. Deprecated: this option
# only affects the legacy retry implementation, which is deprecated and
# will be removed in a future version.
# @option options [ Integer ] :min_pool_size The minimum size of the
# connection pool.
# @option options [ true, false ] :monitoring If false is given, the
Expand Down Expand Up @@ -325,7 +329,9 @@ def hash
# - *:local_threshold*.
# @option options [ Hash ] :read_concern The read concern option.
# @option options [ Float ] :read_retry_interval The interval, in seconds,
# in which reads on a mongos are retried.
# in which reads on a mongos are retried. Deprecated: this option only
# affects the legacy retry implementation, which is deprecated and will
# be removed in a future version.
# @option options [ Symbol ] :replica_set The name of the replica set to
# connect to. Servers not in this replica set will be ignored.
# @option options [ true | false ] :retry_reads If true, modern retryable
Expand Down Expand Up @@ -1444,7 +1450,28 @@ def validate_new_options!(opts)
# Validates all options after they are set on the client.
# This method is intended to catch combinations of options which are
# not allowed.
# Issues a deprecation warning for each legacy retry tuning option that is
# explicitly set. These options only affect the legacy retry
# implementation, which is deprecated and will be removed in a future
# version. Modern retryable reads and writes (enabled by default) ignore
# them.
def deprecate_legacy_retry_options!
%i[max_read_retries read_retry_interval max_write_retries].each do |key|
next unless options.key?(key)

Comment on lines +1459 to +1461
Mongo::Deprecations.warn(
"legacy_retry_option_#{key}",
"The :#{key} option is deprecated. It only affects the legacy retry " \
'implementation, which is deprecated and will be removed in a future ' \
'version. Modern retryable reads and writes are enabled by default ' \
'and do not use this option.'
)
end
end

def validate_options!(addresses = nil, is_srv: nil)
deprecate_legacy_retry_options!

Comment on lines 1472 to +1474
if options[:write] && options[:write_concern] && options[:write] != options[:write_concern]
raise ArgumentError, "If :write and :write_concern are both given, they must be identical: #{options.inspect}"
end
Expand Down
Loading