Class: Mongo::Server::Description::Features
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/mongo/server/description/features.rb |
Overview
Defines behavior around what features a specific server supports.
Constant Summary
-
DEPRECATED_WIRE_VERSIONS =
# File 'lib/mongo/server/description/features.rb', line 107
The wire protocol versions that are deprecated in this version of the driver. Support for these versions will be removed in the future.
If there are multiple currently-deprecated wire versions, this should be set to a range of those versions.
If there is only a single currently-deprecated wire version, this should be set to a range where the min and max are the same value.
If there are no currently-deprecated wire versions, this should be set to an empty range (e.g. the EMPTY_RANGE constant).
6..7
-
DRIVER_TOO_OLD =
# File 'lib/mongo/server/description/features.rb', line 85
::Mongo::Errormessage if the driver is too old for the version of the server."Server at (%s) requires wire version (%s), but this version of the Ruby driver " + "only supports up to (%s)."
-
DRIVER_WIRE_VERSIONS =
# File 'lib/mongo/server/description/features.rb', line 94
The wire protocol versions that this version of the driver supports.
6..25
-
EMPTY_RANGE =
# File 'lib/mongo/server/description/features.rb', line 89
An empty range constant, for use in DEPRECATED_WIRE_VERSIONS.
(0...0).freeze
-
MAPPINGS =
# File 'lib/mongo/server/description/features.rb', line 42
List of features and the wire protocol version they appear in.
Wire protocol versions map to server releases as follows:
-
2 => 2.6
-
3 => 3.0
-
4 => 3.2
-
5 => 3.4
-
6 => 3.6
-
7 => 4.0
-
8 => 4.2
-
9 => 4.4
-
13 => 5.0
-
14 => 5.1
-
17 => 6.0
{ merge_out_on_secondary: 13, get_more_comment: 9, retryable_write_error_label: 9, commit_quorum: 9, # Server versions older than 4.2 do not reliably validate options # provided by the client during findAndModify operations, requiring the # driver to raise client-side errors when those options are provided. find_and_modify_option_validation: 8, sharded_transactions: 8, transactions: 7, scram_sha_256: 7, array_filters: 6, op_msg: 6, sessions: 6, collation: 5, max_staleness: 5, # Server versions older than 3.4 do not reliably validate options # provided by the client during update/delete operations, requiring the # driver to raise client-side errors when those options are provided. update_delete_option_validation: 5, find_command: 4, list_collections: 3, list_indexes: 3, scram_sha_1: 3, write_command: 2, users_info: 2, }.freeze -
-
SERVER_DEPRECATED =
# File 'lib/mongo/server/description/features.rb', line 78
Warning message if the server version is deprecated.
'Server at (%s) reports wire version (%s), but support for that wire version ' \ 'is deprecated and will be removed in a future version of the Ruby driver. ' \ 'Please upgrade your MongoDB server to a newer version soon.'
-
SERVER_TOO_OLD =
# File 'lib/mongo/server/description/features.rb', line 74
::Mongo::Errormessage if the server is too old for this version of the driver."Server at (%s) reports wire version (%s), but this version of the Ruby driver " + "requires at least (%s)."
Class Method Summary
-
.new(server_wire_versions, address = nil) ⇒ Features
constructor
Initialize the features.
Instance Attribute Summary
- #server_wire_versions ⇒ Range readonly
Instance Method Summary
-
#check_driver_support!
Check that there is an overlap between the driver supported wire version range and the server wire version range.
Constructor Details
.new(server_wire_versions, address = nil) ⇒ Features
Initialize the features.
# File 'lib/mongo/server/description/features.rb', line 146
def initialize(server_wire_versions, address = nil) if server_wire_versions.min.nil? raise ArgumentError, "server_wire_versions's min is nil" end if server_wire_versions.max.nil? raise ArgumentError, "server_wire_versions's max is nil" end @server_wire_versions = server_wire_versions @address = address if Mongo::Lint.enabled? freeze end end
Instance Attribute Details
#server_wire_versions ⇒ Range (readonly)
# File 'lib/mongo/server/description/features.rb', line 135
attr_reader :server_wire_versions
Instance Method Details
#check_driver_support!
Check that there is an overlap between the driver supported wire version range and the server wire version range. Also checks to see if the server is using a deprecated wire version.
# File 'lib/mongo/server/description/features.rb', line 167
def check_driver_support! if DEPRECATED_WIRE_VERSIONS.include?(@server_wire_versions.max) feature = "wire_version:#{@address}" Mongo::Deprecations.warn(feature, SERVER_DEPRECATED % [@address, @server_wire_versions.max]) elsif DRIVER_WIRE_VERSIONS.min > @server_wire_versions.max raise Error::UnsupportedFeatures.new(SERVER_TOO_OLD % [@address, @server_wire_versions.max, DRIVER_WIRE_VERSIONS.min]) elsif DRIVER_WIRE_VERSIONS.max < @server_wire_versions.min raise Error::UnsupportedFeatures.new(DRIVER_TOO_OLD % [@address, @server_wire_versions.min, DRIVER_WIRE_VERSIONS.max]) end end