0e831b0b69
Since external diffs are likely to be a bit slower than in-database ones, add a mode that makes diffs external after they've been obsoleted by events. This should strike a balance between performance and disk space. A background cron drives the majority of migrations, since diffs become outdated through user actions.
23 lines
504 B
Ruby
23 lines
504 B
Ruby
# frozen_string_literal: true
|
|
|
|
module MergeRequests
|
|
class MigrateExternalDiffsService < ::BaseService
|
|
MAX_JOBS = 1000.freeze
|
|
|
|
attr_reader :diff
|
|
|
|
def self.enqueue!
|
|
ids = MergeRequestDiff.ids_for_external_storage_migration(limit: MAX_JOBS)
|
|
|
|
MigrateExternalDiffsWorker.bulk_perform_async(ids.map { |id| [id] })
|
|
end
|
|
|
|
def initialize(merge_request_diff)
|
|
@diff = merge_request_diff
|
|
end
|
|
|
|
def execute
|
|
diff.migrate_files_to_external_storage!
|
|
end
|
|
end
|
|
end
|