Sha256: 61d6ab51212c37505755f8c1f55da87075eb0e8d1c4c6819894135eb56ce7c4b
Contents?: true
Size: 981 Bytes
Versions: 4
Compression:
Stored size: 981 Bytes
Contents
# -*- coding: utf-8 -*- require 'tengine_core' require 'mongoid' require 'mongoid/version' if Mongoid::VERSION < "3.0.0" require 'mongoid/cursor' class Mongoid::Cursor # https://github.com/mongoid/mongoid/pull/1609 def each retry_on_connection_failure do while document = cursor.next yield Mongoid::Factory.from_db(klass, document) end end end end module Mongoid::Collections::Retry # https://github.com/mongoid/mongoid/pull/1739 # Mongoid 2.3.x needs additional fix def retry_on_connection_failure retries = 0 begin yield rescue Mongo::ConnectionFailure, Mongo::OperationTimeout, Mongo::OperationFailure => ex raise if ex.class == Mongo::OperationFailure and ex.message !~ /not master/ retries += 1 raise if retries > Mongoid.max_retries_on_connection_failure Kernel.sleep(0.5) log_retry retries retry end end end end
Version data entries
4 entries across 4 versions & 1 rubygems