Skip to content

Commit

Permalink
subject has optional solrcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Dec 7, 2023
1 parent a6d9b9d commit b6c659e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ services:
env_file:
- .env
- env.development
networks:
- mynetwork

volumes:
gem_cache:

networks:
mynetwork:
external: true
6 changes: 3 additions & 3 deletions env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
BIBLIO_SOLR='http://biblio-server/solr'
AUTHOR_SOLR='http://catalog-solr-server/solr'
SOLRCLOUD_URL='http://solr-cloud-server/solr'
BROWSE_SOLR='http://catalog-solr-server/solr'
CALLNUMBER_CORE='callnumbers'
AUTHORITY_CORE='authority_core'
AUTHOR_COLLECTION='author_collection'
AUTHORITY_COLLECTION='authority_collection'
SOLR_USER='solr'
SOLR_PASSWORD='SolrRocks'
SOLR_CLOUD_ON='false'
SOLRCLOUD_ON='false'
2 changes: 1 addition & 1 deletion lib/models/author_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.for(direction:, reference_id:, num_rows_to_display:, original_reference
num_rows_to_display: num_rows_to_display,
original_reference: original_reference,
banner_reference: banner_reference,
browse_solr_client: BrowseSolrClient.new(solr_url: S.author_solr, core: S.author_collection, match_field: "term", q: "browse_field:name", solr_cloud_on: S.solr_cloud_on?)
browse_solr_client: BrowseSolrClient.new(solr_url: S.solrcloud_url, core: S.authority_collection, match_field: "term", q: "browse_field:name", solrcloud_on: S.solrcloud_on?)
)

new(browse_list: browse_list)
Expand Down
2 changes: 1 addition & 1 deletion lib/models/subject_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.for(direction:, reference_id:, num_rows_to_display:, original_reference
num_rows_to_display: num_rows_to_display,
original_reference: original_reference,
banner_reference: banner_reference,
browse_solr_client: BrowseSolrClient.new(core: ENV.fetch("AUTHORITY_CORE"), match_field: "term", q: "browse_field:subject")
browse_solr_client: BrowseSolrClient.new(solr_url: S.solrcloud_url, core: S.authority_collection, match_field: "term", q: "browse_field:subject", solrcloud_on: S.solrcloud_on?)
)

new(browse_list: browse_list)
Expand Down
12 changes: 6 additions & 6 deletions lib/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
Services = Canister.new
S = Services

S.register(:solr_cloud_on?) do
ENV["SOLR_CLOUD_ON"] == "true"
S.register(:solrcloud_on?) do
ENV["SOLRCLOUD_ON"] == "true"
end

S.register(:author_solr) do
ENV["AUTHOR_SOLR"] || ENV["BROWSE_SOLR"]
S.register(:authority_collection) do
S.solrcloud_on? ? ENV["AUTHORITY_COLLECTION"] : ENV["AUTHORITY_CORE"]
end

S.register(:author_collection) do
ENV["AUTHOR_COLLECTION"] || ENV["AUTHORITY_CORE"]
S.register(:solrcloud_url) do
S.solrcloud_on? ? ENV["SOLRCLOUD_URL"] : ENV["BROWSE_SOLR"]
end

[
Expand Down
4 changes: 2 additions & 2 deletions lib/utilities/browse_solr_client.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require "faraday"

class BrowseSolrClient
def initialize(solr_url: ENV.fetch("BROWSE_SOLR"), core: ENV.fetch("CALLNUMBER_CORE"), match_field: "callnumber", q: "*:*", solr_cloud_on: false)
def initialize(solr_url: ENV.fetch("BROWSE_SOLR"), core: ENV.fetch("CALLNUMBER_CORE"), match_field: "callnumber", q: "*:*", solrcloud_on: false)
@conn = Faraday.new(
url: solr_url
) do |f|
f.request :json
f.request :authorization, :basic, ENV["SOLR_USER"], ENV["SOLR_PASSWORD"] if solr_cloud_on
f.request :authorization, :basic, ENV["SOLR_USER"], ENV["SOLR_PASSWORD"] if solrcloud_on
# f.request :retry, {max: 1, retry_statuses: [500]}
f.response :json
end
Expand Down

0 comments on commit b6c659e

Please sign in to comment.