Class: Mongo::ServerSelector::SecondaryPreferred
- Inherits:
-
Object
- Object
- Mongo::ServerSelector::SecondaryPreferred
- Includes:
- Selectable
- Defined in:
- lib/mongo/server_selector/secondary_preferred.rb
Overview
Encapsulates specifications for selecting servers, with
secondaries preferred, given a list of candidates.
Instance Attribute Summary
Attributes included from Selectable
Instance Method Summary collapse
-
#name ⇒ Symbol
Get the name of the server mode type.
-
#slave_ok? ⇒ true
Whether the slaveOk bit should be set on wire protocol messages.
-
#tags_allowed? ⇒ true
Whether tag sets are allowed to be defined for this server preference.
-
#to_mongos ⇒ Hash
Convert this server preference definition into a format appropriate for a mongos server.
Methods included from Selectable
#==, #initialize, #inspect, #local_threshold, #select_server, #server_selection_timeout
Instance Method Details
#name ⇒ Symbol
Get the name of the server mode type.
34 35 36 |
# File 'lib/mongo/server_selector/secondary_preferred.rb', line 34 def name :secondary_preferred 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.
44 45 46 |
# File 'lib/mongo/server_selector/secondary_preferred.rb', line 44 def slave_ok? true end |
#tags_allowed? ⇒ true
Whether tag sets are allowed to be defined for this server preference.
53 54 55 |
# File 'lib/mongo/server_selector/secondary_preferred.rb', line 53 def true end |
#to_mongos ⇒ Hash
Convert this server preference definition into a format appropriate
for a mongos server.
Note that the server preference is not sent to mongos as part of the query
selector if there are no tag sets, for maximum backwards compatibility.
70 71 72 73 74 75 |
# File 'lib/mongo/server_selector/secondary_preferred.rb', line 70 def to_mongos return nil if tag_sets.empty? preference = { mode: 'secondaryPreferred' } preference.merge!({ tags: tag_sets }) preference end |