Class: Mongo::ServerSelector::Nearest

Inherits:
Base
  • Object
show all
Defined in:
lib/mongo/server_selector/nearest.rb

Overview

Encapsulates specifications for selecting near servers given a list

of candidates.

Since:

  • 2.0.0

Constant Summary collapse

SERVER_FORMATTED_NAME =

Name of the this read preference in the server’s format.

Since:

  • 2.5.0

'nearest'.freeze

Instance Attribute Summary

Attributes inherited from Base

#hedge, #max_staleness, #options, #tag_sets

Instance Method Summary collapse

Methods inherited from Base

#==, #candidates, #initialize, #inspect, #local_threshold, #local_threshold_with_cluster, #select_server, #server_selection_timeout, #suitable_servers, #try_select_server

Constructor Details

This class inherits a constructor from Mongo::ServerSelector::Base

Instance Method Details

#hedge_allowed?true

Whether the hedge option is allowed to be defined for this server preference.

Returns:

  • (true)

    true

Since:

  • 2.0.0



63
64
65
# File 'lib/mongo/server_selector/nearest.rb', line 63

def hedge_allowed?
  true
end

#nameSymbol

Get the name of the server mode type.

Examples:

Get the name of the server mode for this preference.

preference.name

Returns:

Since:

  • 2.0.0



37
38
39
# File 'lib/mongo/server_selector/nearest.rb', line 37

def name
  :nearest
end

#slave_ok?true

Whether the slaveOk bit should be set on wire protocol messages.

I.e. whether the operation can be performed on a secondary server.

Returns:

  • (true)

    true

Since:

  • 2.0.0



47
48
49
# File 'lib/mongo/server_selector/nearest.rb', line 47

def slave_ok?
  true
end

#tags_allowed?true

Whether tag sets are allowed to be defined for this server preference.

Returns:

  • (true)

    true

Since:

  • 2.0.0



56
57
58
# File 'lib/mongo/server_selector/nearest.rb', line 56

def tags_allowed?
  true
end

#to_docHash Also known as: to_mongos

Convert this server preference definition into a format appropriate

for sending to a MongoDB server (i.e., as a command field).

Returns:

  • (Hash)

    The server preference formatted as a command field value.

Since:

  • 2.0.0



73
74
75
# File 'lib/mongo/server_selector/nearest.rb', line 73

def to_doc
  full_doc
end