Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rails plugin to automatically reload a Xapian database when models change.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 tasks
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 install.rb
README.rdoc

Xapit Sync

Rails plugin which extends Xapit to provide automatic syncing of the index.

For an alternative solution (currently vaporware) see Xapit Server.

github.com/ryanb/xapit-server/tree/master

Installation

This plugin assumes you have a Rails application using Xapit. For more information see: github.com/ryanb/xapit/tree/master

Install the plugin and run migrations.

script/plugin install git://github.com/ryanb/xapit-sync.git
rake db:migrate

That is all you need to get started in development, but you should see the customize portion below.

How it Works

Xapit Sync is a Rails plugin designed to update only the Xapian records which have changed and then reload the database automatically.

Each time a Xapit member (model) is created, updated, or destroyed it will record that change in a separate database table.

A separate process will spawn (if it isn't already running) which updates the Xapian database with all changes recorded. At the end of this process it will trigger a Rails controller/action which is included in the plugin (using Rails metal and/or engines). This will notify the Rails application that the Xapian database needs to be reloaded.

Customize

You will want to customize Xapit Sync to work with your application in production. It is best to do this at the bottom of the setup_xapit.rb initializer file.

If you have your own queuing system (such as delayed_job) it is better to use that instead of the built-in script runner.

class XapitSyncJob
  def perform
    XapitSync.sync
  end
end

# in config/initializers/setup_xapit.rb
XapitSync.override_syncing do
  Delayed::Job.enqueue XapitSyncJob.new
end

You can also disable the syncing process in certain environments. For example:

XapitSync.override_syncing { } unless Rails.env.production?

You'll likely want to customize which domains are triggered when the syncing finishes in order to reload the Xapian database.

XapitSync.domains = ["localhost:8000", "localhost:8001"] if Rails.env.production?

Unfortunately there is not yet a solution to trigger the reloading if you are using Passenger, so you should disable it in that case.

XapitSync.domains = [] if Rails.env.production?
Something went wrong with that request. Please try again.