Sha256: 40e0197bc9deb6ec2db88d7628ec5488d4520eb40c6e92e8f6ca3a5464efda36

Contents?: true

Size: 985 Bytes

Versions: 6

Compression:

Stored size: 985 Bytes

Contents

require 'active_support/all'
require 'net/protocol'

require_relative 'retryable'
require_relative 'ui'

module Gitlab
  module Triage
    class Network
      include Retryable

      attr_reader :options

      def initialize(adapter, options = {})
        @adapter = adapter
        @options = options
      end

      def query_api(token, url)
        response = {}
        resources = []

        begin
          print '.'
          response = execute_with_retry(Net::ReadTimeout) do
            @adapter.get(token, response.fetch(:next_page_url) { url })
          end
          resources += response.delete(:results)
        end while response.delete(:more_pages)

        resources.map!(&:with_indifferent_access)
      rescue Net::ReadTimeout
        []
      end

      def post_api(token, url, body)
        execute_with_retry(Net::ReadTimeout) do
          @adapter.post(token, url, body)
        end

      rescue Net::ReadTimeout
        false
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitlab-triage-0.6.0 lib/gitlab/triage/network.rb
gitlab-triage-0.5.0 lib/gitlab/triage/network.rb
gitlab-triage-0.4.0 lib/gitlab/triage/network.rb
gitlab-triage-0.3.0 lib/gitlab/triage/network.rb
gitlab-triage-0.2.1 lib/gitlab/triage/network.rb
gitlab-triage-0.2.0 lib/gitlab/triage/network.rb