Method: Moped::ReadPreference::Secondary#with_node

Defined in:
lib/moped/read_preference/secondary.rb

#with_node(cluster, &block) ⇒ Object

Note:

If tag sets are provided then secondary selection will need to match the provided tags.

Select a secondary node from the cluster. If no secondary is available then an exception will be raised.

Examples:

Read from a secondary node from the cluster.

preference.with_node(cluster) do |node|
  node.command(ismaster: 1)
end

Parameters:

  • cluster (Cluster)

    The cluster of nodes to select from.

  • block (Proc)

    The block to execute on the node.

Returns:

  • (Object)

    The result of the block.

Raises:

Since:

  • 2.0.0



43
44
45
46
47
# File 'lib/moped/read_preference/secondary.rb', line 43

def with_node(cluster, &block)
  with_retry(cluster) do
    cluster.with_secondary(&block)
  end
end