Sha256: 9b1beb5d08fa713bac8d96a656cf16f512b9b0340b611a7a882ec947b57bb70b

Contents?: true

Size: 545 Bytes

Versions: 32

Compression:

Stored size: 545 Bytes

Contents

module Gitlab
  module Triage
    module Retryable
      MAX_RETRIES = 3

      attr_accessor :tries

      def execute_with_retry(exception_type = StandardError)
        @tries = 0

        until maximum_retries_reached?
          begin
            @tries += 1
            result = yield
            break
          rescue exception_type
            raise if maximum_retries_reached?
          end
        end

        result
      end

      private

      def maximum_retries_reached?
        tries == MAX_RETRIES
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
gitlab-triage-0.8.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.7.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.6.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.5.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.4.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.3.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.2.1 lib/gitlab/triage/retryable.rb
gitlab-triage-0.2.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.1.0 lib/gitlab/triage/retryable.rb
gitlab-triage-0.0.3 lib/gitlab/triage/retryable.rb
gitlab-triage-0.0.2 lib/gitlab/triage/retryable.rb
gitlab-triage-0.0.1 lib/gitlab/triage/retryable.rb