Class: Kraps::HashPartitioner
- Inherits:
-
Object
- Object
- Kraps::HashPartitioner
- Defined in:
- lib/kraps/hash_partitioner.rb
Instance Method Summary collapse
Instance Method Details
#call(key, num_partitions) ⇒ Object
3 4 5 |
# File 'lib/kraps/hash_partitioner.rb', line 3 def call(key, num_partitions) Digest::SHA1.hexdigest(JSON.generate(key))[0..4].to_i(16) % num_partitions end |