Module: Solrizer::Rabbit

Defined in:
lib/solrizer-rabbit.rb,
lib/solrizer-rabbit/version.rb,
lib/solrizer-rabbit/sharded_indexer.rb,
lib/solrizer-rabbit/buffered_indexer.rb,
lib/solrizer-rabbit/queue_index_worker.rb

Defined Under Namespace

Classes: BufferedIndexer, QueueIndexWorker, ShardedIndexer

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.enqueueObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/solrizer-rabbit.rb', line 13

def self.enqueue
  q = Carrot.queue(queue_name)
  
  connections.each do |conn|
    conn.search(nil) do |object|
      q.publish(object.pid)
    end
  end 

  Carrot.stop
end

.queue_nameObject



9
10
11
# File 'lib/solrizer-rabbit.rb', line 9

def self.queue_name
  ENV['queue'] || 'index'
end

.workObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/solrizer-rabbit.rb', line 25

def self.work
  worker_count = (ENV['threads'] || 1).to_i

  workers = []
  threads = []
  worker_count.times do |n|
    worker = Solrizer::Rabbit::QueueIndexWorker.new
    workers << worker
    threads << Thread.new { worker.run }
  end

  Signal.trap("INT") { workers.each {|w| w.stop} }

  threads.each do |thread|
    thread.join
  end 
  puts "Sending commit to solr"
  ActiveFedora::SolrService.instance.conn.commit
end