Module: Gitlab::GithubImport::ObjectImporter

Extended by:
ActiveSupport::Concern
Included in:
ImportDiffNoteWorker, ImportIssueWorker, ImportLfsObjectWorker, ImportNoteWorker, ImportPullRequestWorker
Defined in:
app/workers/concerns/gitlab/github_import/object_importer.rb

Overview

ObjectImporter defines the base behaviour for every Sidekiq worker that imports a single resource such as a note or pull request.

Instance Method Summary collapse

Instance Method Details

#counterObject


31
32
33
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 31

def counter
  @counter ||= Gitlab::Metrics.counter(counter_name, counter_description)
end

#counter_descriptionObject

Returns the description (as a String) of the Prometheus counter.

Raises:

  • (NotImplementedError)

52
53
54
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 52

def counter_description
  raise NotImplementedError
end

#counter_nameObject

Returns the name (as a Symbol) of the Prometheus counter.

Raises:

  • (NotImplementedError)

47
48
49
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 47

def counter_name
  raise NotImplementedError
end

#import(project, client, hash) ⇒ Object

project - An instance of `Project` to import the data into. client - An instance of `Gitlab::GithubImport::Client` hash - A Hash containing the details of the object to import.


23
24
25
26
27
28
29
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 23

def import(project, client, hash)
  object = representation_class.from_json_hash(hash)

  importer_class.new(object, project, client).execute

  counter.increment
end

#importer_classObject

Returns the class to use for importing the object.

Raises:

  • (NotImplementedError)

42
43
44
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 42

def importer_class
  raise NotImplementedError
end

#representation_classObject

Returns the representation class to use for the object. This class must define the class method `from_json_hash`.

Raises:

  • (NotImplementedError)

37
38
39
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 37

def representation_class
  raise NotImplementedError
end