Class: Mongo::Server::Description::Features
- Inherits:
-
Object
- Object
- Mongo::Server::Description::Features
- Defined in:
- lib/mongo/server/description/features.rb
Overview
Defines behavior around what features a specific server supports.
Constant Summary collapse
- MAPPINGS =
List of features and the wire protocol version they appear in.
Wire protocol versions map to server releases as follows:
-
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, }.freeze
- SERVER_TOO_OLD =
Error message 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).'
- SERVER_DEPRECATED =
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.'
- DRIVER_TOO_OLD =
Error message 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).'
- EMPTY_RANGE =
An empty range constant, for use in DEPRECATED_WIRE_VERSIONS.
(0...0).freeze
- DRIVER_WIRE_VERSIONS =
The wire protocol versions that this version of the driver supports.
8..25
- DEPRECATED_WIRE_VERSIONS =
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).
EMPTY_RANGE
Instance Attribute Summary collapse
-
#server_wire_versions ⇒ Range
readonly
Server_wire_versions The server’s supported wire versions.
Instance Method Summary collapse
-
#check_driver_support! ⇒ Object
Check that there is an overlap between the driver supported wire version range and the server wire version range.
-
#initialize(server_wire_versions, address = nil) ⇒ Features
constructor
Initialize the features.
Constructor Details
#initialize(server_wire_versions, address = nil) ⇒ Features
Initialize the features.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/mongo/server/description/features.rb', line 114 def initialize(server_wire_versions, address = nil) raise ArgumentError, "server_wire_versions's min is nil" if server_wire_versions.min.nil? raise ArgumentError, "server_wire_versions's max is nil" if server_wire_versions.max.nil? @server_wire_versions = server_wire_versions @address = address return unless Mongo::Lint.enabled? freeze end |
Instance Attribute Details
#server_wire_versions ⇒ Range (readonly)
Returns server_wire_versions The server’s supported wire versions.
103 104 105 |
# File 'lib/mongo/server/description/features.rb', line 103 def server_wire_versions @server_wire_versions end |
Instance Method Details
#check_driver_support! ⇒ Object
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.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/mongo/server/description/features.rb', line 132 def check_driver_support! if DEPRECATED_WIRE_VERSIONS.include?(@server_wire_versions.max) feature = "wire_version:#{@address}" Mongo::Deprecations.warn(feature, format(SERVER_DEPRECATED, @address, @server_wire_versions.max)) elsif DRIVER_WIRE_VERSIONS.min > @server_wire_versions.max raise Error::UnsupportedFeatures.new(format(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(format(DRIVER_TOO_OLD, @address, @server_wire_versions.min, DRIVER_WIRE_VERSIONS.max)) end end |