Created
October 10, 2010 04:07
-
-
Save jamesgolick/618930 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def apply[A](attempt: Int)(f: Conn => A): A = { | |
| val node = nextLiveNode() | |
| val pool = node.pool | |
| val connection = pool.borrow() | |
| try { | |
| val value = f(connection) | |
| pool.giveBack(connection) | |
| value | |
| } catch { | |
| case e: Throwable if attempt == maxRetries => pool.invalidate(connection); throw e | |
| case e: Throwable if canRecover(e) => pool.invalidate(connection); failNode(node); apply(attempt + 1)(f) | |
| case e: Throwable => pool.invalidate(connection); throw e | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment