class Dependabot::Clients::BitbucketWithRetries

Constants

RETRYABLE_ERRORS

Public Class Methods

for_bitbucket_dot_org(credentials:) click to toggle source

Constructor methods #

# File lib/dependabot/clients/bitbucket_with_retries.rb, line 17
def self.for_bitbucket_dot_org(credentials:)
  credential =
    credentials.
    select { |cred| cred["type"] == "git_source" }.
    find { |cred| cred["host"] == "bitbucket.org" }

  new(credentials: credential)
end
new(max_retries: 3, **args) click to toggle source

Proxying #

# File lib/dependabot/clients/bitbucket_with_retries.rb, line 30
def initialize(max_retries: 3, **args)
  @max_retries = max_retries || 3
  @client = Bitbucket.new(**args)
end

Public Instance Methods

method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/dependabot/clients/bitbucket_with_retries.rb, line 35
def method_missing(method_name, *args, &block)
  retry_connection_failures do
    if @client.respond_to?(method_name)
      mutatable_args = args.map(&:dup)
      @client.public_send(method_name, *mutatable_args, &block)
    else
      super
    end
  end
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/dependabot/clients/bitbucket_with_retries.rb, line 46
def respond_to_missing?(method_name, include_private = false)
  @client.respond_to?(method_name) || super
end
retry_connection_failures() { || ... } click to toggle source
# File lib/dependabot/clients/bitbucket_with_retries.rb, line 50
def retry_connection_failures
  retry_attempt = 0

  begin
    yield
  rescue *RETRYABLE_ERRORS
    retry_attempt += 1
    retry_attempt <= @max_retries ? retry : raise
  end
end