Extract a base Geo::RegistryFinder

parent 4a131756
module Geo module Geo
class FileRegistryFinder class FileRegistryFinder < RegistryFinder
attr_reader :current_node
def initialize(current_node: nil)
@current_node = current_node
end
def find_failed_objects(batch_size:) def find_failed_objects(batch_size:)
Geo::FileRegistry Geo::FileRegistry
.failed .failed
...@@ -28,7 +22,7 @@ module Geo ...@@ -28,7 +22,7 @@ module Geo
# Selective project replication adds a wrinkle to FDW queries, so # Selective project replication adds a wrinkle to FDW queries, so
# we fallback to the legacy version for now. # we fallback to the legacy version for now.
relation = relation =
if Gitlab::Geo.fdw? && !selective_sync if fdw?
fdw_find_nonreplicated_lfs_objects fdw_find_nonreplicated_lfs_objects
else else
legacy_find_nonreplicated_lfs_objects(except_registry_ids: except_registry_ids) legacy_find_nonreplicated_lfs_objects(except_registry_ids: except_registry_ids)
...@@ -54,7 +48,7 @@ module Geo ...@@ -54,7 +48,7 @@ module Geo
# Selective project replication adds a wrinkle to FDW queries, so # Selective project replication adds a wrinkle to FDW queries, so
# we fallback to the legacy version for now. # we fallback to the legacy version for now.
relation = relation =
if Gitlab::Geo.fdw? && !selective_sync if fdw?
fdw_find_nonreplicated_uploads fdw_find_nonreplicated_uploads
else else
legacy_find_nonreplicated_uploads(except_registry_ids: except_registry_ids) legacy_find_nonreplicated_uploads(except_registry_ids: except_registry_ids)
...@@ -68,10 +62,6 @@ module Geo ...@@ -68,10 +62,6 @@ module Geo
protected protected
def selective_sync
current_node.restricted_project_ids
end
# #
# FDW accessors # FDW accessors
# #
......
module Geo module Geo
class ProjectRegistryFinder class ProjectRegistryFinder < RegistryFinder
attr_reader :current_node
def initialize(current_node: nil)
@current_node = current_node
end
def find_unsynced_projects(batch_size:) def find_unsynced_projects(batch_size:)
relation = relation =
if fdw? if fdw?
...@@ -30,20 +24,10 @@ module Geo ...@@ -30,20 +24,10 @@ module Geo
protected protected
def fdw?
# Selective project replication adds a wrinkle to FDW
# queries, so we fallback to the legacy version for now.
Gitlab::Geo.fdw? && !selective_sync
end
def fdw_table def fdw_table
Geo::Fdw::Project.table_name Geo::Fdw::Project.table_name
end end
def selective_sync
current_node.restricted_project_ids
end
# #
# FDW accessors # FDW accessors
# #
......
module Geo
class RegistryFinder
attr_reader :current_node
def initialize(current_node: nil)
@current_node = current_node
end
protected
def fdw?
# Selective project replication adds a wrinkle to FDW
# queries, so we fallback to the legacy version for now.
Gitlab::Geo.fdw? && !selective_sync
end
def selective_sync
current_node.restricted_project_ids
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