Skip to content

Commit

Permalink
Make the valkyrie index adapter configurable
Browse files Browse the repository at this point in the history
Add configuration for the indexing adapter to make access consistent with other
valkyrie adapters. The one-true-way to access the indexing adapter is now
`Hyrax.indexing_adapter`.

We'll likely only really support the Solr indexing adapter (or things that very
closely conform to its behavior) for the forseeable future.
  • Loading branch information
Tom Johnson committed Nov 6, 2019
1 parent aabf50a commit 6b47ade
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/services/hyrax/solr_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def search_by_id(id, opts = {})
private

def valkyrie_index
Valkyrie::IndexingAdapter.find(:solr_index)
Hyrax.index_adapter
end

def rows_warning
Expand Down
6 changes: 6 additions & 0 deletions lib/hyrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def self.primary_work_type
config.curation_concerns.first
end

##
# @return [Valkyrie::IndexingAdapter]
def self.index_adapter
config.index_adapter
end

##
# The Valkyrie persister used for PCDM models throughout Hyrax
#
Expand Down
12 changes: 12 additions & 0 deletions lib/hyrax/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@ def iiif_metadata_fields
end
attr_writer :iiif_metadata_fields

##
# @return [#save, #save_all, #delete, #wipe] an indexing adapter
def index_adapter
@index_adapter ||= Valkyrie::IndexingAdapter.find(:solr_index)
end

##
# @param [#to_sym] adapter
def index_adapter=(adapter)
@index_adapter ||= Valkyrie::IndexingAdapter.find(adapter.to_sym)
end

attr_writer :index_field_mapper
def index_field_mapper
@index_field_mapper ||= ActiveFedora.index_field_mapper
Expand Down
2 changes: 1 addition & 1 deletion spec/support/clean_solr.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.configure do |config|
config.before(:each, clean_index: true) do
client = Valkyrie::IndexingAdapter.find(:solr_index).connection
client = Hyrax.index_adapter.connection
client.delete_by_query("*:*", params: { softCommit: true })
end
end

0 comments on commit 6b47ade

Please sign in to comment.