diff options
Diffstat (limited to 'lib/bitbucket/connection.rb')
-rw-r--r-- | lib/bitbucket/connection.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb index 64550a0525c..f28b2a0a899 100644 --- a/lib/bitbucket/connection.rb +++ b/lib/bitbucket/connection.rb @@ -2,6 +2,8 @@ module Bitbucket class Connection + include Bitbucket::ExponentialBackoff + DEFAULT_API_VERSION = '2.0' DEFAULT_BASE_URI = 'https://api.bitbucket.org/' DEFAULT_QUERY = {}.freeze @@ -22,7 +24,14 @@ module Bitbucket def get(path, extra_query = {}) refresh! if expired? - response = connection.get(build_url(path), params: @default_query.merge(extra_query)) + response = if Feature.enabled?(:bitbucket_importer_exponential_backoff) + retry_with_exponential_backoff do + connection.get(build_url(path), params: @default_query.merge(extra_query)) + end + else + connection.get(build_url(path), params: @default_query.merge(extra_query)) + end + response.parsed end @@ -44,6 +53,10 @@ module Bitbucket @client ||= OAuth2::Client.new(provider.app_id, provider.app_secret, options) end + def logger + Gitlab::BitbucketImport::Logger + end + def connection @connection ||= OAuth2::AccessToken.new(client, @token, refresh_token: @refresh_token, expires_at: @expires_at, expires_in: @expires_in) end |