class MixedGauge::Routing
Routing
from key to database connection
Public Class Methods
new(cluster_config)
click to toggle source
@param [ClusterConfig] cluster_config
# File lib/mixed_gauge/routing.rb, line 7 def initialize(cluster_config) @cluster_config = cluster_config end
Public Instance Methods
hash_f(key)
click to toggle source
@param [String] key @return [Integer]
# File lib/mixed_gauge/routing.rb, line 21 def hash_f(key) MixedGauge.config.hash_proc.call(key) end
route(key)
click to toggle source
slot can be one of (0..slot_size - 1) @param [String] dist_key @return [String] connection name
# File lib/mixed_gauge/routing.rb, line 14 def route(key) slot = hash_f(key) % @cluster_config.slot_size @cluster_config.fetch(slot) end