Sha256: 142e7367d891cf3a79f28fa16643f779dc194ab8e35ad35625c118876a308c47

Contents?: true

Size: 685 Bytes

Versions: 18

Compression:

Stored size: 685 Bytes

Contents

module Gitlab
  module Triage
    module Retryable
      MAX_RETRIES = 3
      BACK_OFF_SECONDS = 10

      attr_accessor :tries

      def execute_with_retry(exception_types: [StandardError], backoff_exceptions: [])
        @tries = 0

        until maximum_retries_reached?
          begin
            @tries += 1
            return yield
          rescue *exception_types
            raise if maximum_retries_reached?
          rescue *backoff_exceptions
            raise if maximum_retries_reached?

            sleep(BACK_OFF_SECONDS)
          end
        end
      end

      private

      def maximum_retries_reached?
        tries == MAX_RETRIES
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
gitlab-triage-1.29.0 lib/gitlab/triage/retryable.rb
payping-gitlab-triage-0.1.3 lib/gitlab/triage/retryable.rb
payping-gitlab-triage-0.1.2 lib/gitlab/triage/retryable.rb
payping-gitlab-triage-0.1.1 lib/gitlab/triage/retryable.rb
gitlab-triage-1.28.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.27.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.26.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.25.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.24.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.23.1 lib/gitlab/triage/retryable.rb
gitlab-triage-1.23.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.22.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.21.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.20.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.19.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.18.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.17.0 lib/gitlab/triage/retryable.rb
gitlab-triage-1.16.0 lib/gitlab/triage/retryable.rb