Last active
August 29, 2015 14:16
-
-
Save ttanimichi/73ee03d5985a75c3f5d8 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
| module Kernel | |
| def yield_with_retry(limit: 3, before_retrying: ->{}, before_giving_up: ->{}) | |
| limit.times do | |
| begin | |
| return yield | |
| rescue => e | |
| before_retrying.call | |
| end | |
| end | |
| before_giving_up.call | |
| end | |
| end | |
| before_retrying = -> { logger.info "Failed to do something" } | |
| before_giving_up = -> { raise "Give up to do something" } | |
| yield_with_retry(10, before_retrying, before_giving_up) |
rastamhadi
commented
Mar 10, 2015
Author
@rastamhadi 探したら gem あった
https://github.com/nfedyashev/retryable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
