Module: OnlyofficeDigitaloceanWrapper::ExceptionsRetryer
- Included in:
- DigitalOceanWrapper
- Defined in:
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/exceptions_retryer.rb
Overview
Module to ignore DigitalOcean exception if they happen irregularly
Instance Method Summary collapse
-
#retry_exception(exception = DropletKit::Error, retries: 5, timeout: 10) ⇒ Object
Retry if exception happened.
Instance Method Details
#retry_exception(exception = DropletKit::Error, retries: 5, timeout: 10) ⇒ Object
Retry if exception happened
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/exceptions_retryer.rb', line 10 def retry_exception(exception = DropletKit::Error, retries: 5, timeout: 10) try = 0 begin yield rescue exception => e try += 1 logger.error("Error '#{exception}, #{e}' happened during " \ "operation. Retrying #{try} of #{retries}") sleep timeout # Time to cooldown error try <= retries ? retry : raise end end |