Sha256: 65ec10c5a8ed2a4015b12f24b8f0084dd4ea41332481b9865ba274a9dad1b3bd
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require "solrizer-rabbit/version" require "solrizer-fedora" require "solrizer-rabbit/queue_index_worker" require "solrizer-rabbit/buffered_indexer" module Solrizer module Rabbit def self.queue_name ENV['queue'] || 'index' end 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 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 private def self.connections if ActiveFedora.config.sharded? return ActiveFedora.config.credentials.map { |cred| ActiveFedora::RubydoraConnection.new(cred).connection} else return [ActiveFedora::RubydoraConnection.new(ActiveFedora.config.credentials).connection] end end end end load File.join(File.dirname(__FILE__),"tasks/solrizer-rabbit.rake") if defined?(Rake)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solrizer-rabbit-0.0.1 | lib/solrizer-rabbit.rb |