module Sunspot::SessionProxy
This module contains several Session
Proxy implementations, which can be used to decorate one or more Session
objects and add extra functionality. The user can also implement their own Session
Proxy classes; a Session
Proxy must simply implement the same public API as the Sunspot::Session
class.
When implementing a session proxy, some methods of Session
may not be practical, or even logical, to implement. In this case, the method should raise a Sunspot::SessionProxy::NotSupportedError
(several methods in the built-in session proxies raise this error).
To use a session proxy in normal Sunspot
usage, you can use the Sunspot.session=
method, which will cause Sunspot
to delegate all of its session-related class methods (most of them) to the proxy. Session
proxies can also easily be chained, although the details of chaining depend on the proxy implementation.
Example: Chain a MasterSlaveSessionProxy
with a ThreadLocalSessionProxy
¶ ↑
master_session = Sunspot::SessionProxy::ThreadLocalSessionProxy.new slave_session = Sunspot::SessionProxy::ThreadLocalSessionProxy.new master_session.config.solr.url = 'http://master-solr.local:9080/solr' slave_session.config.solr.url = 'http://slave-solr.local:9080/solr' Sunspot.session = Sunspot::SessionProxy::MasterSlaveSessionProxy.new(master_session, slave_session)
Constants
- NotSupportedError