0.0
No commit activity in last 3 years
No release in over 3 years
Because Solr sometimes fails, it happens. It might be a maintenance work you have to do or just Out-Of-Memory problems. If you are running search-sensitive Rails app, you have to deal with it.This gem was developed to postpone your index tasks automatically into a sidekiq queue if Solr engine becomes unavailable
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.1
~> 1.16
~> 10.0
~> 3.6
= 0.59.1
~> 1.3.6

Runtime

 Project Readme

Sunspot Offline

Simple fail over method into your sunspot_rails + sidekiq setup

Build Rubocop Gem Version

Why?

Because Solr sometimes fails, it happens. It might be a maintenance work you have to do or just Out-Of-Memory problems. If you are running search-sensitive Rails app, you have to deal with it. This gem was developed to postpone your index tasks automatically into a sidekiq queue if Solr engine becomes unavailable

Rails Support

Rails 5.0 and higher

Installation

Add this line to your application's Gemfile:

gem 'sunspot_offline'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sunspot_offline

Configuration

By default gem is configured to use built-in workers which will auto-retry indexing in 1 hour is Solr goes offline. This all is configurable, preferable via initializer:

# config/initializers/sunspot_offline.rb
  
SunspotOffline.configure do |config|
  config.retry_delay = 1.hour
end

Valid configuration options

Option Type Default value
index_job Class bundled worker class Sidekiq worker which will retry saving new documents to Solr. Accepts 2 arguments: ActiveRecord class and id (numbers, arrays, and hashes are all valid for this argument)
removal_job Class bundled worker class Sidekiq worker which will retry removing existing documents from Solr. Accepts same set of arguments as index_job.
retry_delay Duration 1 hour Delay in which sidekiq will attempt to run index_job or removal_job
default_queue String 'default' Sidekiq's named queue to use
solr_error_callback Proc(exception) nil A proc which will be executed if Solr is detected to be offline
filter_sidekiq_job_callback Proc(job_class) nil Since some Solr indexing might be happening inside yours sidekiq jobs they dont need to have a custom fail over, sidekiq is able to retry failures by itself. Using this proc you can configure which jobs could be filtered out:
->(job_name) { job_name == 'MySolrIndexJob' }. In this sample MySolrIndexJob wont be applied for a fail over

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Run tests (bundle exec appraisal install && bundle exec appraisal rake)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.