Commit 0198c2e4 authored by Valery Sizov's avatar Valery Sizov

Make generic DestroyWorker for SSF

It will decrease the boilerplate of SSF destroy worker

Apply 1 suggestion(s) to 1 file(s)

Apply 1 suggestion(s) to 1 file(s)
parent 45ba680a
......@@ -48,12 +48,6 @@ module Geo
carrierwave_uploader.path
end
private
def download
::Geo::BlobDownloadService.new(replicator: self).execute
end
def replicate_destroy(event_data)
::Geo::FileRegistryRemovalService.new(
replicable_name,
......@@ -62,6 +56,12 @@ module Geo
).execute
end
private
def download
::Geo::BlobDownloadService.new(replicator: self).execute
end
def deleted_params
{ model_record_id: model_record.id, blob_path: blob_path }
end
......
......@@ -42,7 +42,7 @@ class Geo::BaseRegistry < Geo::TrackingBase
end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
::Geo::DestroyWorker
end
def self.replicator_class
......
......@@ -27,4 +27,8 @@ class Geo::JobArtifactRegistry < Geo::BaseRegistry
delete_worker_class.perform_async(:job_artifact, artifact_id)
end
end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
end
end
......@@ -22,4 +22,8 @@ class Geo::LfsObjectRegistry < Geo::BaseRegistry
delete_worker_class.perform_async(:lfs, lfs_object_id)
end
end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
end
end
......@@ -7,8 +7,4 @@ class Geo::SnippetRepositoryRegistry < Geo::BaseRegistry
MODEL_FOREIGN_KEY = :snippet_repository_id
belongs_to :snippet_repository, class_name: 'SnippetRepository'
def self.delete_worker_class
::Geo::FrameworkRepositoryDestroyWorker
end
end
......@@ -68,6 +68,10 @@ class Geo::UploadRegistry < Geo::BaseRegistry
end
end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
end
def self.with_search(query)
return all if query.nil?
......
......@@ -355,15 +355,15 @@
:weight: 1
:idempotent:
:tags: []
- :name: geo:geo_event
- :name: geo:geo_destroy
:feature_category: :geo_replication
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:idempotent: true
:tags: []
- :name: geo:geo_file_download
- :name: geo:geo_event
:feature_category: :geo_replication
:has_external_dependencies:
:urgency: :low
......@@ -371,7 +371,7 @@
:weight: 1
:idempotent:
:tags: []
- :name: geo:geo_file_registry_removal
- :name: geo:geo_file_download
:feature_category: :geo_replication
:has_external_dependencies:
:urgency: :low
......@@ -379,7 +379,7 @@
:weight: 1
:idempotent:
:tags: []
- :name: geo:geo_file_removal
- :name: geo:geo_file_registry_removal
:feature_category: :geo_replication
:has_external_dependencies:
:urgency: :low
......@@ -387,13 +387,13 @@
:weight: 1
:idempotent:
:tags: []
- :name: geo:geo_framework_repository_destroy
- :name: geo:geo_file_removal
:feature_category: :geo_replication
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent: true
:idempotent:
:tags: []
- :name: geo:geo_hashed_storage_attachments_migration
:feature_category: :geo_replication
......
# frozen_string_literal: true
module Geo
class FrameworkRepositoryDestroyWorker
class DestroyWorker
include ApplicationWorker
include GeoQueue
include ::Gitlab::Geo::LogHelpers
......@@ -11,11 +11,11 @@ module Geo
loggable_arguments 0
def perform(replicable_name, replicable_id)
log_info('Executing Geo::FrameworkRepositoryDestroyWorker', replicable_id: replicable_id, replicable_name: replicable_name)
log_info('Executing Geo::DestroyWorker', replicable_id: replicable_id, replicable_name: replicable_name)
replicator = Gitlab::Geo::Replicator.for_replicable_params(replicable_name: replicable_name, replicable_id: replicable_id)
replicator = ::Gitlab::Geo::Replicator.for_replicable_params(replicable_name: replicable_name, replicable_id: replicable_id)
::Geo::RepositoryRegistryRemovalService.new(replicator).execute
replicator.replicate_destroy({})
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::DestroyWorker, :geo do
let(:replicator) { double(:replicator) }
describe '#perform' do
it 'calls replicator#replicate_destroy' do
expect(replicator).to receive(:replicate_destroy)
expect(Gitlab::Geo::Replicator).to receive(:for_replicable_params).with(replicable_name: 'snippet_repository', replicable_id: 1).and_return(replicator)
described_class.new.perform('snippet_repository', 1)
end
end
include_examples 'an idempotent worker' do
let(:job_args) { ['snippet_repository', 1] }
it 'calls replicator#replicate_destroy' do
allow(Gitlab::Geo::Replicator).to receive(:for_replicable_params).and_return(replicator)
expect(replicator).to receive(:replicate_destroy).exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
subject
end
end
end
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