Commit 17f7bb50 authored by James Fargher's avatar James Fargher

Rename dump_* to enqueue

Now that there aren't separate paths for backup/restore we can name
these more appropriately.
parent a7a06617
...@@ -22,29 +22,29 @@ module EE ...@@ -22,29 +22,29 @@ module EE
end end
end end
override :dump_container override :enqueue_container
def dump_container(container) def enqueue_container(container)
if container.is_a?(Group) if container.is_a?(Group)
dump_group(container) enqueue_group(container)
else else
super super
end end
end end
def dump_group(group) def enqueue_group(group)
strategy.enqueue(group, ::Gitlab::GlRepository::WIKI) strategy.enqueue(group, ::Gitlab::GlRepository::WIKI)
end end
override :dump_consecutive override :enqueue_consecutive
def dump_consecutive def enqueue_consecutive
dump_consecutive_groups enqueue_consecutive_groups
super super
end end
def dump_consecutive_groups def enqueue_consecutive_groups
find_groups_in_batches do |group| find_groups_in_batches do |group|
dump_group(group) enqueue_group(group)
end end
end end
......
...@@ -41,7 +41,7 @@ RSpec.describe Backup::Repositories do ...@@ -41,7 +41,7 @@ RSpec.describe Backup::Repositories do
end end
describe 'command failure' do describe 'command failure' do
it 'dump_group raises an error' do it 'enqueue_group raises an error' do
allow(strategy).to receive(:enqueue).with(anything, Gitlab::GlRepository::WIKI).and_raise(IOError) allow(strategy).to receive(:enqueue).with(anything, Gitlab::GlRepository::WIKI).and_raise(IOError)
expect { subject.dump(max_concurrency: 1, max_storage_concurrency: 1) }.to raise_error(IOError) expect { subject.dump(max_concurrency: 1, max_storage_concurrency: 1) }.to raise_error(IOError)
......
...@@ -13,7 +13,7 @@ module Backup ...@@ -13,7 +13,7 @@ module Backup
strategy.start(:create) strategy.start(:create)
if max_concurrency <= 1 && max_storage_concurrency <= 1 if max_concurrency <= 1 && max_storage_concurrency <= 1
return dump_consecutive return enqueue_consecutive
end end
check_valid_storages! check_valid_storages!
...@@ -24,7 +24,7 @@ module Backup ...@@ -24,7 +24,7 @@ module Backup
threads = Gitlab.config.repositories.storages.keys.map do |storage| threads = Gitlab.config.repositories.storages.keys.map do |storage|
Thread.new do Thread.new do
Rails.application.executor.wrap do Rails.application.executor.wrap do
dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency) enqueue_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency)
rescue StandardError => e rescue StandardError => e
errors << e errors << e
end end
...@@ -42,7 +42,7 @@ module Backup ...@@ -42,7 +42,7 @@ module Backup
def restore def restore
strategy.start(:restore) strategy.start(:restore)
dump_consecutive enqueue_consecutive
ensure ensure
strategy.wait strategy.wait
...@@ -67,22 +67,22 @@ module Backup ...@@ -67,22 +67,22 @@ module Backup
[ProjectRepository, SnippetRepository] [ProjectRepository, SnippetRepository]
end end
def dump_consecutive def enqueue_consecutive
dump_consecutive_projects enqueue_consecutive_projects
dump_consecutive_snippets enqueue_consecutive_snippets
end end
def dump_consecutive_projects def enqueue_consecutive_projects
project_relation.find_each(batch_size: 1000) do |project| project_relation.find_each(batch_size: 1000) do |project|
dump_project(project) enqueue_project(project)
end end
end end
def dump_consecutive_snippets def enqueue_consecutive_snippets
Snippet.find_each(batch_size: 1000) { |snippet| dump_snippet(snippet) } Snippet.find_each(batch_size: 1000) { |snippet| enqueue_snippet(snippet) }
end end
def dump_storage(storage, semaphore, max_storage_concurrency:) def enqueue_storage(storage, semaphore, max_storage_concurrency:)
errors = Queue.new errors = Queue.new
queue = InterlockSizedQueue.new(1) queue = InterlockSizedQueue.new(1)
...@@ -95,7 +95,7 @@ module Backup ...@@ -95,7 +95,7 @@ module Backup
end end
begin begin
dump_container(container) enqueue_container(container)
rescue StandardError => e rescue StandardError => e
errors << e errors << e
break break
...@@ -117,22 +117,22 @@ module Backup ...@@ -117,22 +117,22 @@ module Backup
end end
end end
def dump_container(container) def enqueue_container(container)
case container case container
when Project when Project
dump_project(container) enqueue_project(container)
when Snippet when Snippet
dump_snippet(container) enqueue_snippet(container)
end end
end end
def dump_project(project) def enqueue_project(project)
strategy.enqueue(project, Gitlab::GlRepository::PROJECT) strategy.enqueue(project, Gitlab::GlRepository::PROJECT)
strategy.enqueue(project, Gitlab::GlRepository::WIKI) strategy.enqueue(project, Gitlab::GlRepository::WIKI)
strategy.enqueue(project, Gitlab::GlRepository::DESIGN) strategy.enqueue(project, Gitlab::GlRepository::DESIGN)
end end
def dump_snippet(snippet) def enqueue_snippet(snippet)
strategy.enqueue(snippet, Gitlab::GlRepository::SNIPPET) strategy.enqueue(snippet, Gitlab::GlRepository::SNIPPET)
end end
......
...@@ -54,7 +54,7 @@ RSpec.describe Backup::Repositories do ...@@ -54,7 +54,7 @@ RSpec.describe Backup::Repositories do
end end
describe 'command failure' do describe 'command failure' do
it 'dump_project raises an error' do it 'enqueue_project raises an error' do
allow(strategy).to receive(:enqueue).with(anything, Gitlab::GlRepository::PROJECT).and_raise(IOError) allow(strategy).to receive(:enqueue).with(anything, Gitlab::GlRepository::PROJECT).and_raise(IOError)
expect { subject.dump(max_concurrency: 1, max_storage_concurrency: 1) }.to raise_error(IOError) expect { subject.dump(max_concurrency: 1, max_storage_concurrency: 1) }.to raise_error(IOError)
...@@ -117,7 +117,7 @@ RSpec.describe Backup::Repositories do ...@@ -117,7 +117,7 @@ RSpec.describe Backup::Repositories do
end end
describe 'command failure' do describe 'command failure' do
it 'dump_project raises an error' do it 'enqueue_project raises an error' do
allow(strategy).to receive(:enqueue).and_raise(IOError) allow(strategy).to receive(:enqueue).and_raise(IOError)
expect { subject.dump(max_concurrency: 1, max_storage_concurrency: max_storage_concurrency) }.to raise_error(IOError) expect { subject.dump(max_concurrency: 1, max_storage_concurrency: max_storage_concurrency) }.to raise_error(IOError)
......
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