Class: Gitlab::GithubImport::SequentialImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::SequentialImporter
- Defined in:
- lib/gitlab/github_import/sequential_importer.rb
Overview
The SequentialImporter imports a GitHub project in a single thread, without using Sidekiq. This makes it useful for testing purposes as well as Rake tasks, but it should be avoided for anything else in favour of the parallel importer.
Constant Summary collapse
- SEQUENTIAL_IMPORTERS =
[ Importer::LabelsImporter, Importer::MilestonesImporter, Importer::ReleasesImporter ].freeze
- PARALLEL_IMPORTERS =
[ Importer::ProtectedBranchesImporter, Importer::PullRequestsImporter, Importer::IssuesImporter, Importer::DiffNotesImporter, Importer::NotesImporter, Importer::LfsObjectsImporter ].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, token: nil, host: nil) ⇒ SequentialImporter
constructor
project - The project to import the data into.
Constructor Details
#initialize(project, token: nil, host: nil) ⇒ SequentialImporter
project - The project to import the data into. token - The token to use for the GitHub API. host - The GitHub hostname. If nil, github.com will be used.
30 31 32 33 34 |
# File 'lib/gitlab/github_import/sequential_importer.rb', line 30 def initialize(project, token: nil, host: nil) @project = project @client = GithubImport .new_client_for(project, token: token, host: host, parallel: false) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/gitlab/github_import/sequential_importer.rb', line 10 def client @client end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
10 11 12 |
# File 'lib/gitlab/github_import/sequential_importer.rb', line 10 def project @project end |
Instance Method Details
#execute ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/gitlab/github_import/sequential_importer.rb', line 36 def execute metrics.track_start_import begin Importer::RepositoryImporter.new(project, client).execute SEQUENTIAL_IMPORTERS.each do |klass| klass.new(project, client).execute end rescue StandardError => e Gitlab::Import::ImportFailureService.track( project_id: project.id, error_source: self.class.name, exception: e, fail_import: true, metrics: true ) raise(e) end PARALLEL_IMPORTERS.each do |klass| klass.new(project, client, parallel: false).execute end metrics.track_finished_import true end |