public
Description: Rails plugin to automatically reload a Xapian database when models change.
Homepage:
Clone URL: git://github.com/ryanb/xapit-sync.git
name age message
file .gitignore Thu May 28 16:09:44 -0700 2009 initial structure [ryanb]
file LICENSE Thu Jun 18 11:10:25 -0700 2009 generating migration file when installing, and ... [ryanb]
file README.rdoc Mon Jun 22 13:02:18 -0700 2009 removing protocol from domains in readme [ryanb]
file Rakefile Thu May 28 16:09:44 -0700 2009 initial structure [ryanb]
directory app/ Thu Jun 18 10:06:56 -0700 2009 adding xapit controller with reload action [ryanb]
directory config/ Thu Jun 18 10:06:56 -0700 2009 adding xapit controller with reload action [ryanb]
file init.rb Thu Jun 18 11:28:18 -0700 2009 fixing typo in init.rb [ryanb]
file install.rb Thu Jun 18 11:10:25 -0700 2009 generating migration file when installing, and ... [ryanb]
directory lib/ Mon Jun 22 13:03:34 -0700 2009 close database when pushing changes to ensure i... [ryanb]
directory spec/ Mon Jun 22 13:03:34 -0700 2009 close database when pushing changes to ensure i... [ryanb]
directory tasks/ Thu May 28 16:09:44 -0700 2009 initial structure [ryanb]
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?