Skip to content

Commit

Permalink
Merge 2a6e502 into ac2ad4a
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jun 27, 2018
2 parents ac2ad4a + 2a6e502 commit b39f91d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
6 changes: 6 additions & 0 deletions lib/blacklight/abstract_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def search(_params = {})
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 @@ -22,6 +22,14 @@ def search params = {}
send_and_receive blacklight_config.solr_path, params.reverse_merge(qt: blacklight_config.qt)
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
# @see [RSolr::Client#send_and_receive]
Expand Down
15 changes: 2 additions & 13 deletions lib/railties/blacklight.rake
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,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 b39f91d

Please sign in to comment.