Module: MongodbLogger::ReplicaSetHelper

Included in:
Logger
Defined in:
lib/mongodb_logger/replica_set_helper.rb

Instance Method Summary collapse

Instance Method Details

#rescue_connection_failure(max_retries = 40) ⇒ Object

Use retry alg from mongodb to gobble up connection failures during replica set master vote Defaults to a 10 second wait



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mongodb_logger/replica_set_helper.rb', line 5

def rescue_connection_failure(max_retries = 40)
  success = false
  retries = 0
  while !success
    begin
      yield
      success = true
    rescue mongo_error_type => e
      raise e if (retries += 1) >= max_retries
      sleep 0.25
    end
  end
end