| Class | Attempt |
| In: |
lib/attempt.rb
|
| Parent: | Object |
The Attempt class encapsulates methods related to multiple attempts at running the same method before actually failing.
| VERSION | = | '0.4.0'.freeze | The version of the attempt library. |
| increment | [RW] | If set, this increments the interval with each failed attempt by that number of seconds. |
| interval | [RW] | Number of seconds to wait between attempts. The default is 60. |
| level | [RW] | Determines which exception level to check when looking for errors to retry. The default is ‘Exception’ (i.e. all errors). |
| log | [RW] | If you provide an IO handle to this option then errors that would have been raised are sent to that handle. |
| timeout | [RW] | If set, the code block is further wrapped in a timeout block. |
| tries | [RW] | Number of attempts to make before failing. The default is 3. |
| warnings | [RW] | A boolean value that determines whether errors that would have been raised should be sent to STDERR as warnings. The default is true. |
Creates and returns a new Attempt object. The supported keyword options are as follows:
until the maximum number of attempts has been made. The default is true.
proc in a SafeTimeout block. The default is false.
Example:
a = Attempt.new(tries: 5, increment: 10, timeout: true)
a.attempt{ http.get("http://something.foo.com") }
Attempt to perform the operation in the provided block up to tries times, sleeping interval between each try.
You will not typically use this method directly, but the Kernel#attempt method instead.