Created
July 3, 2012 21:20
-
-
Save mediocretes/3043269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mongo::Collection | |
def timeout_find(*args) | |
return old_find(*args) unless @catch_timeouts | |
begin | |
old_find *args | |
rescue Mongo::OperationTimeout | |
I.increment "sm.op_timeouts" | |
return [].each | |
end | |
end | |
alias :old_find :find | |
alias :find :timeout_find | |
def timeout_find_one(*args) | |
return old_find_one(*args) unless @catch_timeouts | |
begin | |
old_find_one *args | |
rescue Mongo::OperationTimeout | |
I.increment "sm.op_timeouts" | |
return nil | |
end | |
end | |
alias :old_find_one :find_one | |
alias :find_one :timeout_find_one | |
def catch_timeouts! | |
@catch_timeouts = true | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment