Class: ActiveRecord::ShardFor::HashModuloRouter

Inherits:
ConnectionRouter show all
Defined in:
lib/activerecord/shard_for/hash_modulo_router.rb

Instance Attribute Summary

Attributes inherited from ConnectionRouter

#cluster_config

Instance Method Summary collapse

Methods inherited from ConnectionRouter

#fetch_connection_name, #initialize

Constructor Details

This class inherits a constructor from ActiveRecord::ShardFor::ConnectionRouter

Instance Method Details

#route(key) ⇒ Object

Parameters:

  • key (String)

    sharding key



7
8
9
# File 'lib/activerecord/shard_for/hash_modulo_router.rb', line 7

def route(key)
  hash(key) % connection_count
end