Class: Mongo::ServerSelector::Primary
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Base
|
|
Instance Chain:
self,
Base
|
|
Inherits: |
Mongo::ServerSelector::Base
|
Defined in: | lib/mongo/server_selector/primary.rb |
Overview
Encapsulates specifications for selecting the primary server given a list
of candidates.
Constant Summary
-
SERVER_FORMATTED_NAME =
Name of the this read preference in the server’s format.
'primary'.freeze
Class Method Summary
Instance Attribute Summary
-
#hedge_allowed? ⇒ false
readonly
Whether the hedge option is allowed to be defined for this server preference.
-
#secondary_ok? ⇒ false
readonly
Internal use only
Internal use only
Whether the secondaryOk bit should be set on wire protocol messages.
-
#tags_allowed? ⇒ false
readonly
Whether tag sets are allowed to be defined for this server preference.
- #max_staleness_allowed? ⇒ Boolean readonly private
Base
- Inherited
Instance Method Summary
-
#name ⇒ Symbol
Get the name of the server mode type.
-
#to_doc ⇒ Hash
Convert this server preference definition into a format appropriate.
-
#to_mongos ⇒ Hash | nil
Convert this server preference definition into a value appropriate.
-
#select_in_replica_set(candidates) ⇒ Array
private
Select the primary server from a list of candidates.
Base
- Inherited
#== | Check equality of two server selectors. |
#candidates | Returns servers of acceptable types from the cluster. |
#inspect | Inspect the server selector. |
#local_threshold | Get the local threshold boundary for nearest selection in seconds. |
#local_threshold_with_cluster, | |
#select_server | Select a server from the specified cluster, taking into account mongos pinning for the specified session. |
#server_selection_timeout | Get the timeout for server selection. |
#suitable_servers | Returns servers satisfying the server selector from the cluster. |
#try_select_server | Tries to find a suitable server, returns the server if one is available or nil if there isn’t a suitable server. |
#filter_stale_servers, | |
#full_doc | Convert this server preference definition into a format appropriate. |
#match_tag_sets | Select the servers matching the defined tag sets. |
#near_servers | Select the near servers from a list of provided candidates, taking the. |
#primary | Select the primary from a list of provided candidates. |
#secondaries | Select the secondaries from a list of provided candidates. |
#select_server_impl | Parameters and return values are the same as for select_server, only the |
#server_selection_diagnostic_message | Creates a diagnostic message when server selection fails. |
#suitable_server | Returns a server from the list of servers that is suitable for executing the operation. |
#validate!, #validate_max_staleness_support!, #validate_max_staleness_value!, #validate_max_staleness_value_early!, | |
#wait_for_server_selection | Waits for server state changes in the specified cluster. |
Instance Attribute Details
#hedge_allowed? ⇒ false
(readonly)
Whether the hedge option is allowed to be defined for this server preference.
# File 'lib/mongo/server_selector/primary.rb', line 66
def hedge_allowed? false end
#max_staleness_allowed? ⇒ Boolean
(readonly, private)
# File 'lib/mongo/server_selector/primary.rb', line 105
def max_staleness_allowed? false end
#secondary_ok? ⇒ false
(readonly)
Whether the secondaryOk bit should be set on wire protocol messages.
I.e. whether the operation can be performed on a secondary server.
# File 'lib/mongo/server_selector/primary.rb', line 50
def secondary_ok? false end
#tags_allowed? ⇒ false
(readonly)
Whether tag sets are allowed to be defined for this server preference.
# File 'lib/mongo/server_selector/primary.rb', line 59
def false end
Instance Method Details
#name ⇒ Symbol
Get the name of the server mode type.
# File 'lib/mongo/server_selector/primary.rb', line 41
def name :primary end
#select_in_replica_set(candidates) ⇒ Array
(private)
Select the primary server from a list of candidates.
# File 'lib/mongo/server_selector/primary.rb', line 101
def select_in_replica_set(candidates) primary(candidates) 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).
# File 'lib/mongo/server_selector/primary.rb', line 76
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.
# File 'lib/mongo/server_selector/primary.rb', line 90
def to_mongos nil end