Sha256: 96a30a983816d5a2a3240f2d970d922331dc4520f3249e2092e7bfd64daa55a7

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

require 'sunspot'
require 'sunspot/session_proxy/master_slave_with_failover_session_proxy'
require 'sunspot/rails/failover/exception_handler_adapter'

module Sunspot
  module Rails
    module Failover
      class << self
        attr_accessor :exception_handler
        
        def setup
          Sunspot.session = if Rails.configuration.has_master?
            SessionProxy::MasterSlaveWithFailoverSessionProxy.new(
              SessionProxy::ThreadLocalSessionProxy.new(master_config),
              SessionProxy::ThreadLocalSessionProxy.new(slave_config)
            )
          else
            SessionProxy::ThreadLocalSessionProxy.new(slave_config)
          end
        end
        
      private
      
        def slave_config
          Rails.send :slave_config, Rails.configuration
        end
        
        def master_config
          Rails.send :master_config, Rails.configuration
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sunspot-rails-failover-0.0.5 lib/sunspot/rails/failover.rb