Sha256: 94724a7f7f6c8cf171ab360926fbd0511f87a7aefea9a2cfd98819b4f204c40c

Contents?: true

Size: 170 Bytes

Versions: 8

Compression:

Stored size: 170 Bytes

Contents

module Kraps
  class HashPartitioner
    def call(key, num_partitions)
      Digest::SHA1.hexdigest(JSON.generate(key))[0..4].to_i(16) % num_partitions
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kraps-0.10.0 lib/kraps/hash_partitioner.rb
kraps-0.9.0 lib/kraps/hash_partitioner.rb
kraps-0.8.0 lib/kraps/hash_partitioner.rb
kraps-0.7.0 lib/kraps/hash_partitioner.rb
kraps-0.6.0 lib/kraps/hash_partitioner.rb
kraps-0.5.0 lib/kraps/hash_partitioner.rb
kraps-0.4.0 lib/kraps/hash_partitioner.rb
kraps-0.3.0 lib/kraps/hash_partitioner.rb