Add a class method to delete registries

parent 2e1fff6c
......@@ -30,4 +30,8 @@ class Geo::BaseRegistry < Geo::TrackingBase
bulk_insert!(records, returns: :ids)
end
def self.delete_for_model_ids(ids)
raise NotImplementedError, "#{self.class} does not implement #{__method__}"
end
end
......@@ -33,14 +33,20 @@ class Geo::JobArtifactRegistry < Geo::BaseRegistry
# TODO: remove once `success` column has a default value set
# https://gitlab.com/gitlab-org/gitlab/-/issues/214407
def self.insert_for_model_ids(ids)
records = ids.map do |id|
new(artifact_id: id, success: false, created_at: Time.zone.now)
def self.insert_for_model_ids(attrs)
records = attrs.map do |artifact_id, _|
new(artifact_id: artifact_id, success: false, created_at: Time.zone.now)
end
bulk_insert!(records, returns: :ids)
end
def self.delete_for_model_ids(attrs)
records = attrs.map do |artifact_id, _|
::Geo::FileRegistryRemovalWorker.perform_async(:job_artifact, artifact_id) # rubocop:disable CodeReuse/Worker
end
end
def self.replication_enabled?
JobArtifactUploader.object_store_enabled? ? Gitlab::Geo.current_node.sync_object_storage? : true
end
......
......@@ -26,4 +26,10 @@ class Geo::LfsObjectRegistry < Geo::BaseRegistry
def self.has_create_events?
false
end
def self.delete_for_model_ids(ids)
ids.map do |id|
::Geo::FileRegistryRemovalWorker.perform_async(:lfs, id) # rubocop:disable CodeReuse/Worker
end
end
end
......@@ -36,6 +36,12 @@ class Geo::UploadRegistry < Geo::BaseRegistry
bulk_insert!(records, returns: :ids)
end
def self.delete_for_model_ids(attrs)
attrs.map do |file_id, file_type|
::Geo::FileRegistryRemovalWorker.perform_async(file_type, file_id) # rubocop:disable CodeReuse/Worker
end
end
def self.with_search(query)
return all if query.nil?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment