Sha256: 03de472bb4b2d34636c993b4d571f5afbd07f99dcdd75ec9de90010b6e6ca173

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

module Sunspot
  module SessionProxy
    class MasterSlaveWithFailoverSessionProxy < MasterSlaveSessionProxy
      
      attr_accessor :exception
      
      def commit
        with_exception_handling do
          master_session.commit
        end
      end
      
      def search(*types, &block)
        [slave_session, master_session].any? do |session|
          with_exception_handling { session.search(*types, &block) }
        end or raise(exception)
      end
      
    private
    
      def with_exception_handling
        yield
      rescue Exception => exception
        Sunspot::Rails::Failover::ExceptionHandlerAdapter.handle(exception)
        self.exception = exception
        false
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunspot-rails-failover-0.0.4 lib/sunspot-rails-failover/master_slave_with_failover_session_proxy.rb
sunspot-rails-failover-0.0.3 lib/sunspot-rails-failover/master_slave_with_failover_session_proxy.rb