Skip to content

Commit

Permalink
Merge 8809982 into 99878d4
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jul 26, 2018
2 parents 99878d4 + 8809982 commit 9811dea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
7 changes: 6 additions & 1 deletion lib/blacklight/abstract_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ def search(_params = {})
raise NotImplementedError
end

##
# Query the fields that exist from the index
# @return [Hash]
def reflect_fields
raise NotImplementedError
end

##
# Is the repository in a working state?
def ping
raise NotImplementedError
end

private

def connection_config
Expand Down
8 changes: 8 additions & 0 deletions lib/blacklight/solr/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def reflect_fields
send_and_receive('admin/luke', params: { fl: '*', 'json.nl' => 'map' })['fields']
end

##
# @return [boolean] true if the repository is reachable
def ping
response = connection.send_and_receive 'admin/ping', {}
Blacklight.logger.info("Ping [#{connection.uri}] returned: '#{response['status']}'")
response['status'] == "OK"
end

##
# Execute a solr query
# TODO: Make this private after we have a way to abstract admin/luke and ping
Expand Down
15 changes: 2 additions & 13 deletions lib/railties/blacklight.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,12 @@ namespace :blacklight do
namespace :check do
desc "Check the Solr connection and controller configuration"
task :solr, [:controller_name] => [:environment] do
errors = 0
verbose = ENV.fetch('VERBOSE', false).present?

conn = Blacklight.default_index.connection
puts "[#{conn.uri}]"

print " - admin/ping: "
begin
response = conn.send_and_receive 'admin/ping', {}
puts response['status']
errors += 1 unless response['status'] == "OK"
exit 1 unless Blacklight.default_index.ping
rescue => e
errors += 1
puts e.to_s
exit 1
end

exit 1 if errors > 0
end

task :controller, [:controller_name] => [:environment] do |_, args|
Expand Down

0 comments on commit 9811dea

Please sign in to comment.