Module: Mongo
- Defined in:
- lib/disbatch.rb
Class Method Summary collapse
-
.try(max_retries = 4, interval = 0.5) ⇒ Object
Wrap a MongoDB operation for retry.
Class Method Details
.try(max_retries = 4, interval = 0.5) ⇒ Object
Wrap a MongoDB operation for retry
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/disbatch.rb', line 61 def self.try(max_retries=4,interval=0.5) retries = 0 begin yield rescue Mongo::ConnectionFailure => ex retries +=1 raise ex if retries > max_retries sleep(interval) retry end end |