blob: 8075bd015c2be2d87f5a8dc536ef08a85008ed16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
|
# frozen_string_literal: true
module Packages
module Maven
module Metadata
class SyncWorker
include ApplicationWorker
sidekiq_options retry: 3
include Gitlab::Utils::StrongMemoize
queue_namespace :package_repositories
feature_category :package_registry
tags :exclude_from_kubernetes
deduplicate :until_executing
idempotent!
loggable_arguments 2
SyncError = Class.new(StandardError)
def perform(user_id, project_id, package_name)
@user_id = user_id
@project_id = project_id
@package_name = package_name
return unless valid?
result = ::Packages::Maven::Metadata::SyncService.new(container: project, current_user: user, params: { package_name: @package_name })
.execute
if result.success?
log_extra_metadata_on_done(:message, result.message)
else
raise SyncError.new(result.message)
end
raise SyncError.new(result.message) unless result.success?
end
private
def valid?
@package_name.present? && user.present? && project.present?
end
def user
strong_memoize(:user) do
User.find_by_id(@user_id)
end
end
def project
strong_memoize(:project) do
Project.find_by_id(@project_id)
end
end
end
end
end
end
|