Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

ryanb/xapit-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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?

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages