1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00
Maybe/lib/retryable.rb
Jose Farias 7ae25dd6df
Implement Synth as an exchange rate provider (#574)
* Implement Synth as an exchange rate provider

* Add assertions to provider interface test

* Assert the correct provider error is raised

* Remove unnecessary parens
2024-03-27 11:16:00 -04:00

19 lines
336 B
Ruby

module Retryable
def retrying(retryable_errors = [], max_retries: 3)
attempts = 0
begin
on_last_attempt = attempts == max_retries - 1
yield on_last_attempt
rescue *retryable_errors => e
attempts += 1
if attempts < max_retries
retry
else
raise e
end
end
end
end