Sha256: 8135e5129182bfa1235597dbc8807f44f7b2af9df3a51f206b8f6bccc644bc6c

Contents?: true

Size: 578 Bytes

Versions: 10

Compression:

Stored size: 578 Bytes

Contents

module PactBroker
  module Client
    class Retry

      def self.until_true options = {}
        max_tries = options.fetch(:times, 3)
        tries = 0
        while true
          begin
            return yield
          rescue StandardError => e
            tries += 1
            $stderr.puts "Error publishing pact - #{e.message}, attempt #{tries} of #{max_tries}"
            sleep options
            raise e if max_tries == tries
          end
        end
      end

      def self.sleep options
        Kernel.sleep options.fetch(:sleep, 5)
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pact_broker-client-1.6.0 lib/pact_broker/client/retry.rb
pact_broker-client-1.5.0 lib/pact_broker/client/retry.rb
pact_broker-client-1.4.0 lib/pact_broker/client/retry.rb
pact_broker-client-1.3.0 lib/pact_broker/client/retry.rb
pact_broker-client-1.2.0 lib/pact_broker/client/retry.rb
pact_broker-client-1.1.0 lib/pact_broker/client/retry.rb
pact_broker-client-1.0.3 lib/pact_broker/client/retry.rb
pact_broker-client-1.0.2 lib/pact_broker/client/retry.rb
pact_broker-client-1.0.1 lib/pact_broker/client/retry.rb
pact_broker-client-1.0.0 lib/pact_broker/client/retry.rb