lib/moped/read_preference/selectable.rb
# Execute the provided block on the cluster and retry if the execution
# fails.
#
# @api private
#
# @example Execute with retry.
#   preference.with_retry(cluster) do
#     cluster.with_primary do |node|
#       node.refresh
#     end
#   end
#
# @param [ Cluster ] cluster The cluster.
# @param [ Integer ] retries The number of times to retry.
#
# @return [ Object ] The result of the block.
#
# @since 2.0.0
Execute the provided block on the cluster and retry if the execution
fails.
Execute the provided block on the cluster and retry if the execution fails .
def with_retry(cluster, retries = cluster.max_retries, &block)
        begin
          block.call
        rescue Errors::ConnectionFailure => e
          if retries > 0
            Loggable.warn("  MOPED:", "Retrying connection attempt #{retries} more time(s).", "n/a")
            sleep(cluster.retry_interval)
            cluster.refresh
            with_retry(cluster, retries - 1, &block)
          else
            raise e
          end
        end
      end
def with_retry ( cluster , retries = cluster . max_retries , & block ) begin block . call rescue Errors :: ConnectionFailure => e if retries > 0 Loggable . warn ( "  MOPED:" , "Retrying connection attempt #{retries} more time(s)." , "n/a" ) sleep ( cluster . retry_interval ) cluster . refresh with_retry ( cluster , retries - 1 , & block ) else raise e end end end
Execute the provided block on the cluster and retry if the execution
fails.
Execute the provided block on the cluster and retry if the execution fails .
The result of the block.
The result of the block .
 Object 
cluster
retries
max_retries
block
retries The number of times to retry.
retries The number of times to retry .
api
None
example
Execute with retry. preference.with_retry(cluster) do cluster.with_primary do |node| node.refresh end end
Execute with retry . preference . with_retry ( cluster ) do cluster . with_primary do |node| node . refresh end end
since
None