Features — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Server::Description::Features

Inherits:

Object

Defined in:

lib/mongo/server/description/features.rb

Overview

Defines behavior around what features a specific server supports.

Constant Summarycollapse

MAPPINGS =

List of features and the wire protocol version they appear in.

Wire protocol versions map to server releases as follows:

{ merge_out_on_secondary: 13, get_more_comment: 9, retryable_write_error_label: 9, commit_quorum: 9, 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, 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_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)."

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)."

DRIVER_WIRE_VERSIONS =

The wire protocol versions that this version of the driver supports.

(6..25).freeze

Instance Attribute Summary collapse

Instance Method Summarycollapse

Constructor Details

#initialize(server_wire_versions, address = nil) ⇒ Features

118 119 120 121 122 123 124 125 126 127 128 129 130 131 # File 'lib/mongo/server/description/features.rb', line 118 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

Returns server_wire_versions The server’s supported wire versions.

107 108 109 # File 'lib/mongo/server/description/features.rb', line 107 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.
143 144 145 146 147 148 149 150 151 152 153 # File 'lib/mongo/server/description/features.rb', line 143 def check_driver_support! if 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