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

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/server/description/features.rb

Overview

Defines behaviour around what features a specific server supports.

Since:

  • 2.0.0

Constant Summary

MAPPINGS =

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

Since:

  • 2.0.0

{
  :array_filters => 6,
  :op_msg => 6,
  :sessions => 6,
  :collation => 5,
  :max_staleness => 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.

Since:

  • 2.5.0

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

Since:

  • 2.5.0

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

Since:

  • 2.0.0

(2..6).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_wire_versions, address = nil) ⇒ Features

Initialize the features.

Examples:

Initialize the features.

Features.new(0..3)

Parameters:

  • server_wire_versions (Range)

    The server supported wire versions.

Since:

  • 2.0.0



89
90
91
92
# File 'lib/mongo/server/description/features.rb', line 89

def initialize(server_wire_versions, address = nil)
  @server_wire_versions = server_wire_versions
  @address = address
end

Instance Attribute Details

#server_wire_versionsRange (readonly)

Returns server_wire_versions The server's supported wire versions.

Returns:

  • (Range)

    server_wire_versions The server's supported wire versions.

Since:

  • 2.0.0



78
79
80
# File 'lib/mongo/server/description/features.rb', line 78

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.

Examples:

Verify the wire version overlap.

features.check_driver_support!

Raises:

Since:

  • 2.5.1



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/mongo/server/description/features.rb', line 104

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