Class: Stellr::Strategies::Queueing
- Defined in:
- lib/stellr/strategies/queueing.rb
Overview
Queueing strategy. Any index modifying methods return immediately, actions are queued and executed asynchronously in order of arrival.
Unless you’re using the static collection type, indexes will be switched whenever options (which defaults to 200) is reached, and when the queue is empty.
with static collections manually calling switch is required, and this call will block until the switch is actually done.
However this does not mean that all records from the queue have been processed, the switch may also occur between processing of add_record or add_records calls.
FIXME fix this: switch should be an operation that is enqueued just like add_record so it occurs at the point in time the client desires. Is implicit switching really that useful? Definitely not with static collections…
Instance Method Summary collapse
- #add_record(record, boost = nil) ⇒ Object
- #add_records(records) ⇒ Object
- #delete_record(record) ⇒ Object
-
#initialize(collection, options) ⇒ Queueing
constructor
A new instance of Queueing.
Methods inherited from Base
Methods included from Utils::Shutdown
Constructor Details
#initialize(collection, options) ⇒ Queueing
Returns a new instance of Queueing.
24 25 26 27 28 29 |
# File 'lib/stellr/strategies/queueing.rb', line 24 def initialize( collection, ) super collection, @options[:max_batch_size] ||= 200 @queue = Queue.new @thread = spawn_indexing_thread end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stellr::Strategies::Base
Instance Method Details
#add_record(record, boost = nil) ⇒ Object
31 32 33 |
# File 'lib/stellr/strategies/queueing.rb', line 31 def add_record( record, boost = nil ) enqueue :add, [record, boost] end |
#add_records(records) ⇒ Object
35 36 37 |
# File 'lib/stellr/strategies/queueing.rb', line 35 def add_records(records) enqueue :bulk_add, records end |
#delete_record(record) ⇒ Object
39 40 41 |
# File 'lib/stellr/strategies/queueing.rb', line 39 def delete_record( record ) enqueue :delete, record end |