Sha256: 2dbd31f29f79f1ff5733f9edd93be37485f396cc636658f3dfd4223943efd13f

Contents?: true

Size: 1.22 KB

Versions: 32

Compression:

Stored size: 1.22 KB

Contents

module Riddle
  class Configuration
    class DistributedIndex < Riddle::Configuration::Section
      self.settings = [:type, :local, :agent, :agent_blackhole,
        :agent_connect_timeout, :agent_query_timeout]
      
      attr_accessor :name, :local_indexes, :remote_indexes, :agent_blackhole,
        :agent_connect_timeout, :agent_query_timeout
      
      def initialize(name)
        @name             = name
        @local_indexes    = []
        @remote_indexes   = []
        @agent_blackhole  = []
      end
      
      def type
        "distributed"
      end
      
      def local
        self.local_indexes
      end
      
      def agent
        agents = remote_indexes.collect { |index| index.remote }.uniq
        agents.collect { |agent|
          agent + ":" + remote_indexes.select { |index|
            index.remote == agent
          }.collect { |index| index.name }.join(",")
        }
      end
            
      def render
        raise ConfigurationError unless valid?
        
        (
          ["index #{name}", "{"] +
          settings_body +
          ["}", ""]
        ).join("\n")
      end
      
      def valid?
        @local_indexes.length > 0 || @remote_indexes.length > 0
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 4 rubygems

Version Path
hariton-thinking-sphinx-1.2.11.2 vendor/riddle/lib/riddle/configuration/distributed_index.rb
hariton-thinking-sphinx-1.2.11 vendor/riddle/lib/riddle/configuration/distributed_index.rb
hariton-thinking-sphinx-1.2.7.0 vendor/riddle/lib/riddle/configuration/distributed_index.rb
hariton-thinking-sphinx-1.2.7.1 vendor/riddle/lib/riddle/configuration/distributed_index.rb
riddle-1.3.3 lib/riddle/configuration/distributed_index.rb
riddle-1.3.2 lib/riddle/configuration/distributed_index.rb
riddle-1.3.1 lib/riddle/configuration/distributed_index.rb
riddle-1.3.0 lib/riddle/configuration/distributed_index.rb
riddle-1.2.2 lib/riddle/configuration/distributed_index.rb
riddle-1.2.1 lib/riddle/configuration/distributed_index.rb
riddle-1.2.0 lib/riddle/configuration/distributed_index.rb
riddle-1.1.0 lib/riddle/configuration/distributed_index.rb
skalee-thinking-sphinx-1.3.14.2 vendor/riddle/lib/riddle/configuration/distributed_index.rb
skalee-thinking-sphinx-1.3.14.1 vendor/riddle/lib/riddle/configuration/distributed_index.rb
riddle-1.0.12 lib/riddle/configuration/distributed_index.rb
riddle-1.0.11 lib/riddle/configuration/distributed_index.rb
riddle-1.0.10 lib/riddle/configuration/distributed_index.rb
riddle-1.0.9 lib/riddle/configuration/distributed_index.rb
riddle-1.0.8 lib/riddle/configuration/distributed_index.rb
riddle-1.0.7 lib/riddle/configuration/distributed_index.rb