Class: Lazylead::ORM::Retry
- Inherits:
-
Object
- Object
- Lazylead::ORM::Retry
- Extended by:
- Forwardable
- Defined in:
- lib/lazylead/model.rb
Overview
A task which support retry in case of failure.
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(orig, log = Log.new) ⇒ Retry
constructor
A new instance of Retry.
Constructor Details
Instance Method Details
#exec ⇒ Object
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/lazylead/model.rb', line 216 def exec retries ||= 0 @orig.exec @orig rescue StandardError => e sleep(props.fetch("attempt_wait", 0).to_f) if props.key? "attempt_wait" retry if (retries += 1) < props.fetch("attempt", 0).to_i raise e if props.key? "rethrow" @orig end |