class MixedGauge::Config

Holding global configuration

Constants

DEFAULT_HASH_FUNCTION

Attributes

cluster_configs[R]
hash_proc[R]

Public Class Methods

new() click to toggle source
# File lib/mixed_gauge/config.rb, line 10
def initialize
  @cluster_configs = {}
  @hash_proc = DEFAULT_HASH_FUNCTION
end

Public Instance Methods

define_cluster(cluster_name, &block) click to toggle source

Define config for specific cluster. See README.md for example. @param [Symbol] cluster_name @yield [MixedGauge::ClusterConfig] @raise [RuntimeError] When this cluster config is invalid.

# File lib/mixed_gauge/config.rb, line 20
def define_cluster(cluster_name, &block)
  cluster_config = ClusterConfig.new(cluster_name)
  cluster_config.instance_eval(&block)
  cluster_config.validate_config!
  @cluster_configs[cluster_name] = cluster_config
end
fetch_cluster_config(cluster_name) click to toggle source

@param [Symbol] cluster_name @return [MixedGauge::ClusterConfig]

# File lib/mixed_gauge/config.rb, line 29
def fetch_cluster_config(cluster_name)
  @cluster_configs.fetch(cluster_name)
end
register_hash_function() { |'test value'| ... } click to toggle source

Register arbitrary hash function. Hash function must be a proc and must return integer. See README.md for example.

# File lib/mixed_gauge/config.rb, line 36
def register_hash_function(&block)
  raise ArgumentError if block.arity != 1
  raise ArgumentError unless yield('test value').is_a? Integer
  @hash_proc = block
end