README.md in kraps-0.2.0 vs README.md in kraps-0.3.0
- old
+ new
@@ -141,20 +141,21 @@
of `(key, value)` pairs, the number of partitions specifies how your data gets
split. Kraps assigns every `key` to a partition, either using a custom
`partitioner` or the default built in hash partitioner. The hash partitioner
simply calculates a hash of your key modulo the number of partitions and the
resulting partition number is the partition where the respective key is
-assigned to. A partitioner is a callable which gets the key as argument and
-returns a partition number. The built in hash partitioner looks similar to this
-one:
+assigned to. A partitioner is a callable which gets the key and the number of
+partitions as argument and returns a partition number. The built in hash
+partitioner looks similar to this one:
```ruby
-partitioner = proc { |key| Digest::SHA1.hexdigest(key.inspect)[0..4].to_i(16) % 128 } # 128 partitions
+partitioner = proc { |key, num_partitions| Digest::SHA1.hexdigest(key.inspect)[0..4].to_i(16) % num_partitions }
```
Please note, it's important that the partitioner and the specified number of
partitions stays in sync. When you use a custom partitioner, please make sure
-that the partitioner operates on the same number of partitions you specify.
+that the partitioner correctly returns a partition number in the range of
+`0...num_partitions`.
## Datatypes
Be aware that Kraps converts everything you pass to it to JSON sooner or later,
i.e. symbols will be converted to strings, etc. Therefore, it is recommended to