Class: PactBroker::Client::Retry
- Inherits:
-
Object
- Object
- PactBroker::Client::Retry
- Defined in:
- lib/pact_broker/client/retry.rb
Class Method Summary collapse
Class Method Details
.sleep(options) ⇒ Object
20 21 22 |
# File 'lib/pact_broker/client/retry.rb', line 20 def self.sleep Kernel.sleep .fetch(:sleep, 5) end |
.until_true(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pact_broker/client/retry.rb', line 5 def self.until_true = {} max_tries = .fetch(:times, 3) tries = 0 while true begin return yield rescue StandardError => e tries += 1 $stderr.puts "Error publishing pact - #{e.}, attempt #{tries} of #{max_tries}" sleep raise e if max_tries == tries end end end |