Sha256: 690ada9f67f890e092e985396006b1b9a523a388034edb87abcaebd1e25563a9

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

module Riddle
  class Configuration
    class DistributedIndex < Riddle::Configuration::Section
      def self.settings
        [
          :type, :local, :agent, :agent_blackhole,
          :agent_connect_timeout, :agent_query_timeout
        ]
      end

      attr_accessor :name, :local_indices, :remote_indices, :agent_blackhole,
        :agent_connect_timeout, :agent_query_timeout

      def initialize(name)
        @name             = name
        @local_indices    = []
        @remote_indices   = []
        @agent_blackhole  = []
      end

      def type
        "distributed"
      end

      def local
        self.local_indices
      end

      def agent
        agents = remote_indices.collect { |index| index.remote }.uniq
        agents.collect { |agent|
          agent + ":" + remote_indices.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_indices.length > 0 || @remote_indices.length > 0
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
riddle-2.2.0 lib/riddle/configuration/distributed_index.rb
riddle-2.1.0 lib/riddle/configuration/distributed_index.rb
riddle-2.0.0 lib/riddle/configuration/distributed_index.rb
riddle-1.5.12 lib/riddle/configuration/distributed_index.rb
riddle-1.5.11 lib/riddle/configuration/distributed_index.rb
riddle-1.5.10 lib/riddle/configuration/distributed_index.rb
riddle-1.5.9 lib/riddle/configuration/distributed_index.rb
riddle-1.5.8 lib/riddle/configuration/distributed_index.rb
riddle-1.5.7 lib/riddle/configuration/distributed_index.rb
riddle-1.5.6 lib/riddle/configuration/distributed_index.rb
riddle-1.5.5 lib/riddle/configuration/distributed_index.rb
riddle-1.5.4 lib/riddle/configuration/distributed_index.rb
riddle-1.5.3 lib/riddle/configuration/distributed_index.rb
riddle-1.5.2 lib/riddle/configuration/distributed_index.rb
riddle-1.5.1 lib/riddle/configuration/distributed_index.rb
riddle-1.5.0 lib/riddle/configuration/distributed_index.rb