Rename syncable to registry_class

Rename this method make the finder class
closer to a Geo replicator.
parent bd4f368d
...@@ -31,7 +31,7 @@ module Geo ...@@ -31,7 +31,7 @@ module Geo
.map! { |id, uploader| [id, uploader.sub(/Uploader\z/, '').underscore] } .map! { |id, uploader| [id, uploader.sub(/Uploader\z/, '').underscore] }
tracked = tracked =
syncable registry_class
.model_id_in(range) .model_id_in(range)
.pluck(:file_id, :file_type) .pluck(:file_id, :file_type)
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
...@@ -46,7 +46,7 @@ module Geo ...@@ -46,7 +46,7 @@ module Geo
::Upload.replicables_for_geo_node ::Upload.replicables_for_geo_node
end end
def syncable def registry_class
Geo::UploadRegistry Geo::UploadRegistry
end end
end end
......
...@@ -5,34 +5,34 @@ module Geo ...@@ -5,34 +5,34 @@ module Geo
# @!method registry_count # @!method registry_count
# Return a count of the registry records for the tracked file_type(s) # Return a count of the registry records for the tracked file_type(s)
def registry_count def registry_count
syncable.count registry_class.count
end end
# @!method count_synced # @!method count_synced
# Return a count of the registry records for the tracked file_type(s) # Return a count of the registry records for the tracked file_type(s)
# that are synced # that are synced
def count_synced def count_synced
syncable.synced.count registry_class.synced.count
end end
# @!method count_failed # @!method count_failed
# Return a count of the registry records for the tracked file_type(s) # Return a count of the registry records for the tracked file_type(s)
# that are sync failed # that are sync failed
def count_failed def count_failed
syncable.failed.count registry_class.failed.count
end end
# @!method count_synced_missing_on_primary # @!method count_synced_missing_on_primary
# Return a count of the registry records for the tracked file_type(s) # Return a count of the registry records for the tracked file_type(s)
# that are synced and missing on the primary # that are synced and missing on the primary
def count_synced_missing_on_primary def count_synced_missing_on_primary
syncable.synced.missing_on_primary.count registry_class.synced.missing_on_primary.count
end end
# @!method count_registry # @!method count_registry
# Return a count of the registry records for the tracked file_type(s) # Return a count of the registry records for the tracked file_type(s)
def count_registry def count_registry
syncable.count registry_class.count
end end
# @!method find_registry_differences # @!method find_registry_differences
...@@ -55,7 +55,7 @@ module Geo ...@@ -55,7 +55,7 @@ module Geo
# @return [Array] the first element is an Array of untracked IDs, and the second element is an Array of tracked IDs that are unused # @return [Array] the first element is an Array of untracked IDs, and the second element is an Array of tracked IDs that are unused
def find_registry_differences(range) def find_registry_differences(range)
source_ids = replicables.id_in(range).pluck(replicable_primary_key) # rubocop:disable CodeReuse/ActiveRecord source_ids = replicables.id_in(range).pluck(replicable_primary_key) # rubocop:disable CodeReuse/ActiveRecord
tracked_ids = syncable.pluck_model_ids_in_range(range) tracked_ids = registry_class.pluck_model_ids_in_range(range)
untracked_ids = source_ids - tracked_ids untracked_ids = source_ids - tracked_ids
unused_tracked_ids = tracked_ids - source_ids unused_tracked_ids = tracked_ids - source_ids
...@@ -84,7 +84,7 @@ module Geo ...@@ -84,7 +84,7 @@ module Geo
# #
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_never_synced_registries(batch_size:, except_ids: []) def find_never_synced_registries(batch_size:, except_ids: [])
syncable registry_class
.never .never
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.limit(batch_size) .limit(batch_size)
...@@ -101,7 +101,7 @@ module Geo ...@@ -101,7 +101,7 @@ module Geo
# #
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_failed_registries(batch_size:, except_ids: []) def find_retryable_failed_registries(batch_size:, except_ids: [])
syncable registry_class
.failed .failed
.retry_due .retry_due
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
...@@ -119,7 +119,7 @@ module Geo ...@@ -119,7 +119,7 @@ module Geo
# #
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_synced_missing_on_primary_registries(batch_size:, except_ids: []) def find_retryable_synced_missing_on_primary_registries(batch_size:, except_ids: [])
syncable registry_class
.synced .synced
.missing_on_primary .missing_on_primary
.retry_due .retry_due
...@@ -128,9 +128,9 @@ module Geo ...@@ -128,9 +128,9 @@ module Geo
end end
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
# @!method syncable # @!method registry_class
# Return an ActiveRecord::Base class for the tracked file_type(s) # Return an ActiveRecord::Base class for the tracked file_type(s)
def syncable def registry_class
raise NotImplementedError, raise NotImplementedError,
"#{self.class} does not implement #{__method__}" "#{self.class} does not implement #{__method__}"
end end
...@@ -143,11 +143,11 @@ module Geo ...@@ -143,11 +143,11 @@ module Geo
"#{self.class} does not implement #{__method__}" "#{self.class} does not implement #{__method__}"
end end
# @!method syncable # @!method registry_class
# Return the fully qualified name of the replicable primary key for the # Return the fully qualified name of the replicable primary key for the
# tracked file_type(s) # tracked file_type(s)
def replicable_primary_key def replicable_primary_key
syncable::MODEL_CLASS.arel_table[:id] registry_class::MODEL_CLASS.arel_table[:id]
end end
def local_storage_only? def local_storage_only?
......
...@@ -6,7 +6,7 @@ module Geo ...@@ -6,7 +6,7 @@ module Geo
::Ci::JobArtifact.replicables_for_geo_node ::Ci::JobArtifact.replicables_for_geo_node
end end
def syncable def registry_class
Geo::JobArtifactRegistry Geo::JobArtifactRegistry
end end
end end
......
...@@ -6,7 +6,7 @@ module Geo ...@@ -6,7 +6,7 @@ module Geo
local_storage_only? ? lfs_objects.with_files_stored_locally : lfs_objects local_storage_only? ? lfs_objects.with_files_stored_locally : lfs_objects
end end
def syncable def registry_class
Geo::LfsObjectRegistry Geo::LfsObjectRegistry
end end
......
...@@ -6,7 +6,7 @@ RSpec.describe Geo::FileRegistryFinder, :geo do ...@@ -6,7 +6,7 @@ RSpec.describe Geo::FileRegistryFinder, :geo do
context 'with abstract methods' do context 'with abstract methods' do
%w[ %w[
replicables replicables
syncable registry_class
].each do |required_method| ].each do |required_method|
it "requires subclasses to implement #{required_method}" do it "requires subclasses to implement #{required_method}" do
expect { subject.send(required_method) }.to raise_error(NotImplementedError) expect { subject.send(required_method) }.to raise_error(NotImplementedError)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
RSpec.shared_examples 'a file registry finder' do RSpec.shared_examples 'a file registry finder' do
it 'responds to file registry finder methods' do it 'responds to file registry finder methods' do
file_registry_finder_methods = %i{ file_registry_finder_methods = %i{
syncable registry_class
registry_count registry_count
count_synced count_synced
count_failed count_failed
......
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