Sha256: 1c67f02a02c137daa67baee88a6cfe8aa18fbb5ba15ae7bf9c7d9cba181871a2
Contents?: true
Size: 1.14 KB
Versions: 5
Compression:
Stored size: 1.14 KB
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 @cache = Hash.new { |hash, key| hash[key] = {} } end def query_api_cached(token, url) @cache.dig(token, url) || @cache[token][url] = query_api(token, url) 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
5 entries across 5 versions & 1 rubygems