Class: Gitlab::GithubGistsImport::Importer::GistsImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubGistsImport::Importer::GistsImporter
- Defined in:
- lib/gitlab/github_gists_import/importer/gists_importer.rb
Defined Under Namespace
Classes: RESULT_CONTEXT
Constant Summary collapse
- ALREADY_IMPORTED_CACHE_KEY =
'github-gists-importer/already-imported/%{user}'
Instance Attribute Summary collapse
-
#already_imported_cache_key ⇒ Object
readonly
Returns the value of attribute already_imported_cache_key.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(user, token) ⇒ GistsImporter
constructor
A new instance of GistsImporter.
Constructor Details
#initialize(user, token) ⇒ GistsImporter
Returns a new instance of GistsImporter.
12 13 14 15 16 |
# File 'lib/gitlab/github_gists_import/importer/gists_importer.rb', line 12 def initialize(user, token) @user = user @client = Gitlab::GithubImport::Client.new(token, parallel: true) @already_imported_cache_key = format(ALREADY_IMPORTED_CACHE_KEY, user: user.id) end |
Instance Attribute Details
#already_imported_cache_key ⇒ Object (readonly)
Returns the value of attribute already_imported_cache_key.
7 8 9 |
# File 'lib/gitlab/github_gists_import/importer/gists_importer.rb', line 7 def already_imported_cache_key @already_imported_cache_key end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/gitlab/github_gists_import/importer/gists_importer.rb', line 7 def client @client end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/gitlab/github_gists_import/importer/gists_importer.rb', line 7 def user @user end |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitlab/github_gists_import/importer/gists_importer.rb', line 18 def execute waiter = spread_parallel_import expire_already_imported_cache! RESULT_CONTEXT.new(success?: true, waiter: waiter) rescue Gitlab::GithubImport::RateLimitError => e RESULT_CONTEXT.new(success?: false, error: e, next_attempt_in: client.rate_limit_resets_in) rescue StandardError => e RESULT_CONTEXT.new(success?: false, error: e) end |