Sha256: 8404a00a8edbed77361c7ba725209939454a4d5bf6cd877d41b1350279a96429

Contents?: true

Size: 721 Bytes

Versions: 4

Compression:

Stored size: 721 Bytes

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require './test/test_helper'
require './test/tools/repl_set_manager'

module ReplicaSetTest

  def self.rs
    unless defined?(@rs)
      @rs = ReplSetManager.new
      @rs.start_set
    end
    @rs
  end

  def rs
    ReplicaSetTest.rs
  end

  # Generic code for rescuing connection failures and retrying operations.
  # This could be combined with some timeout functionality.
  def rescue_connection_failure(max_retries=30)
    retries = 0
    begin
      yield
    rescue Mongo::ConnectionFailure => ex
      puts "Rescue attempt #{retries}: from #{ex}"
      retries += 1
      raise ex if retries > max_retries
      sleep(2)
      retry
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo-1.5.2 test/replica_sets/rs_test_helper.rb
mongo-1.5.1 test/replica_sets/rs_test_helper.rb
mongo-1.5.0 test/replica_sets/rs_test_helper.rb
mongo-1.5.0.rc0 test/replica_sets/rs_test_helper.rb