mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
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
This commit is contained in:
19
lib/retryable.rb
Normal file
19
lib/retryable.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
Reference in New Issue
Block a user