Class: Mongo::ServerSelector::Primary
- Defined in:
- lib/mongo/server_selector/primary.rb
Overview
Encapsulates specifications for selecting the primary server given a list
of candidates.
Constant Summary collapse
- SERVER_FORMATTED_NAME =
Name of the this read preference in the server’s format.
'primary'.freeze
Instance Attribute Summary
Attributes inherited from Base
#hedge, #max_staleness, #options, #tag_sets
Instance Method Summary collapse
-
#hedge_allowed? ⇒ false
Whether the hedge option is allowed to be defined for this server preference.
-
#name ⇒ Symbol
Get the name of the server mode type.
-
#slave_ok? ⇒ false
Whether the slaveOk bit should be set on wire protocol messages.
-
#tags_allowed? ⇒ false
Whether tag sets are allowed to be defined for this server preference.
-
#to_doc ⇒ Hash
Convert this server preference definition into a format appropriate for sending to a MongoDB server (i.e., as a command field).
-
#to_mongos ⇒ Hash | nil
Convert this server preference definition into a value appropriate for sending to a mongos.
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? ⇒ false
Whether the hedge option is allowed to be defined for this server preference.
64 65 66 |
# File 'lib/mongo/server_selector/primary.rb', line 64 def hedge_allowed? false end |
#name ⇒ Symbol
Get the name of the server mode type.
38 39 40 |
# File 'lib/mongo/server_selector/primary.rb', line 38 def name :primary end |
#slave_ok? ⇒ false
Whether the slaveOk bit should be set on wire protocol messages.
I.e. whether the operation can be performed on a secondary server.
48 49 50 |
# File 'lib/mongo/server_selector/primary.rb', line 48 def slave_ok? false end |
#tags_allowed? ⇒ false
Whether tag sets are allowed to be defined for this server preference.
57 58 59 |
# File 'lib/mongo/server_selector/primary.rb', line 57 def false end |
#to_doc ⇒ Hash
Convert this server preference definition into a format appropriate
for sending to a MongoDB server (i.e., as a command field).
74 75 76 |
# File 'lib/mongo/server_selector/primary.rb', line 74 def to_doc { mode: SERVER_FORMATTED_NAME } end |
#to_mongos ⇒ Hash | nil
Convert this server preference definition into a value appropriate
for sending to a mongos.
This method may return nil if the read preference should not be sent to a mongos.
88 89 90 |
# File 'lib/mongo/server_selector/primary.rb', line 88 def to_mongos nil end |