Class: Dependabot::RegistryClient

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/registry_client.rb

Constant Summary collapse

CachedErrorType =
T.type_alias { T.any(Excon::Error::Timeout, Excon::Error::Socket) }

Class Method Summary collapse

Class Method Details

.clear_cache!Object



65
66
67
# File 'lib/dependabot/registry_client.rb', line 65

def self.clear_cache!
  @cached_errors = {}
end

.get(url:, headers: {}, options: {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dependabot/registry_client.rb', line 29

def self.get(url:, headers: {}, options: {})
  raise T.must(cached_error_for(url)) if cached_error_for(url)

  Excon.get(
    url,
    idempotent: true,
    **SharedHelpers.excon_defaults({ headers: headers }.merge(options)),
    retry_interval: 5
  )
rescue Excon::Error::Timeout, Excon::Error::Socket => e
  cache_error(url, e)
  raise e
end

.head(url:, headers: {}, options: {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dependabot/registry_client.rb', line 51

def self.head(url:, headers: {}, options: {})
  raise T.must(cached_error_for(url)) if cached_error_for(url)

  Excon.head(
    url,
    idempotent: true,
    **SharedHelpers.excon_defaults({ headers: headers }.merge(options))
  )
rescue Excon::Error::Timeout, Excon::Error::Socket => e
  cache_error(url, e)
  raise e
end