Class | Moped::ReadPreference::Nearest |
In: |
lib/moped/read_preference/nearest.rb
|
Parent: | Object |
Execute the provided block on the node with the lowest latency, allowing either primary or secondary.
@example Read from the nearest node in the cluster.
preference.with_node(cluster) do |node| node.command(ismaster: 1) end
@note If tag sets are provided then selection will need to
match the provided tags.
@param [ Cluster ] cluster The cluster of nodes to select from. @param [ Proc ] block The block to execute on the node.
@raise [ Errors::ConnectionFailure ] If no node was available in the
cluster.
@return [ Object ] The result of the block.
@since 2.0.0