| Module | Mongo::ServerSelector::Selectable |
| In: |
lib/mongo/server_selector/selectable.rb
|
Provides common behavior for filtering a list of servers by server mode or tag set.
@since 2.0.0
| max_staleness | [R] |
@return [ Integer ] max_staleness The maximum replication lag, in seconds,
that a
secondary can suffer and still be eligible for a read. @since 2.4.0 |
| options | [R] | @return [ Hash ] options The options. |
| tag_sets | [R] | @return [ Array ] tag_sets The tag sets used to select servers. |
Initialize the server selector.
@example Initialize the selector.
Mongo::ServerSelector::Secondary.new(:tag_sets => [{'dc' => 'nyc'}])
@example Initialize the preference with no options.
Mongo::ServerSelector::Secondary.new
@param [ Hash ] options The server preference options.
@option options [ Integer ] :local_threshold The local threshold boundary for
nearest selection in seconds.
@option options [ Integer ] max_staleness The maximum replication lag,
in seconds, that a secondary can suffer and still be eligible for a read. A value of -1 is treated identically to nil, which is to not have a maximum staleness.
@raise [ Error::InvalidServerPreference ] If tag sets are specified
but not allowed.
@since 2.0.0
Check equality of two server selector.
@example Check server selector equality.
preference == other
@param [ Object ] other The other preference.
@return [ true, false ] Whether the objects are equal.
@since 2.0.0
Get the potential candidates to select from the cluster.
@example Get the server candidates.
selectable.candidates(cluster)
@param [ Cluster ] cluster The cluster.
@return [ Array<Server> ] The candidate servers.
@since 2.4.0
Inspect the server selector.
@example Inspect the server selector.
selector.inspect
@return [ String ] The inspection.
@since 2.2.0
Get the local threshold boundary for nearest selection in seconds.
@example Get the local threshold.
selector.local_threshold
@return [ Float ] The local threshold.
@since 2.0.0
@deprecated This setting is now taken from the cluster options when a server is selected.
Will be removed in 3.0.
Select a server from eligible candidates.
@example Select a server from the cluster.
selector.select_server(cluster)
@param [ Mongo::Cluster ] cluster The cluster from which to select an eligible server.
@return [ Mongo::Server ] A server matching the server preference.
@since 2.0.0