def with_secondary(&block)
      available_nodes = available_secondary_nodes
      while node = available_nodes.shift
        begin
          return yield(node)
        rescue Errors::ConnectionFailure, Errors::ReplicaSetReconfigured => e
          next
        end
      end
      raise Errors::ConnectionFailure, "Could not connect to a secondary node for replica set #{inspect}"
    end
def with_secondary(&block)
      available_nodes = available_secondary_nodes
      while node = available_nodes.shift
        begin
          return yield(node)
        rescue Errors::ConnectionFailure, Errors::ReplicaSetReconfigured => e
          next
        end
      end
      raise Errors::ConnectionFailure, "Could not connect to a secondary node for replica set #{inspect}"
    end
Yields a secondary node if available, otherwise the primary node. This
 method will retry the block in case of connection errors.

 @example Yield the secondary to the block.
   cluster.with_secondary do |node|
     # ...
   end

 @param [ Integer ] retries The number of times to retry.

 @raises [ ConnectionFailure ] When no primary node can be found

 @return [ Object ] The result of the yield.

 @since 1.0.0