Commit 18bf543f authored by Valery Sizov's avatar Valery Sizov

Make Elasticsearch indexer run as an async task

parent c322ced6
......@@ -5,6 +5,7 @@ v 8.10.0 (unreleased)
- Fix EE keys fingerprint add index migration if came from CE
- Add todos for MR approvers !547
- Isolate EE LDAP library code in EE module (Part 1) !511
- Make Elasticsearch indexer run as an async task
v 8.9.6
- Avoid adding index for key fingerprint if it already exists. !539
......
......@@ -74,17 +74,9 @@ class GitPushService < BaseService
CreateCommitBuildsService.new.execute(@project, current_user, build_push_data, mirror_update: mirror_update)
ProjectCacheWorker.perform_async(@project.id)
index_commits_blobs if current_application_settings.elasticsearch_indexing?
if current_application_settings.elasticsearch_indexing?
ElasticCommitIndexerWorker.perform_async(@project.id, params[:oldrev], params[:newrev])
end
def index_commits_blobs
indexer = Gitlab::Elastic::Indexer.new
indexer.run(
@project.id,
project.repository.path_to_repo,
params[:oldrev],
params[:newrev]
)
end
def perform_housekeeping
......
class ElasticCommitIndexerWorker
include Sidekiq::Worker
sidekiq_options queue: :elasticsearch
def perform(project_id, oldrev, newrev)
project = Project.find(project_id)
indexer = Gitlab::Elastic::Indexer.new
indexer.run(
project_id,
project.repository.path_to_repo,
oldrev,
newrev
)
end
end
require 'spec_helper'
describe ElasticCommitIndexerWorker do
let(:project) { create(:project) }
subject { described_class.new }
describe '#perform' do
it 'runs indexer' do
expect_any_instance_of(Gitlab::Elastic::Indexer).to receive(:run)
subject.perform(project.id, '0000', '0000')
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