Sha256: 926e6aca335f3ccdf9add629128c727e0b6de29d39059cf77c6eb394b12a9852
Contents?: true
Size: 588 Bytes
Versions: 1
Compression:
Stored size: 588 Bytes
Contents
require 'digest/md5' module MixedGauge # Routing from key to database connection class Routing # @param [ClusterConfig] cluster_config def initialize(cluster_config) @cluster_config = cluster_config end # slot can be one of (0..slot_size - 1) # @param [String] dist_key # @return [String] connection name def route(key) slot = hash_f(key) % @cluster_config.slot_size @cluster_config.fetch(slot) end # @param [String] key # @return [Integer] def hash_f(key) MixedGauge.config.hash_proc.call(key) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mixed_gauge-1.2.0 | lib/mixed_gauge/routing.rb |