CosIdShardingDecorator
class CosIdShardingDecorator(sharding: PreciseSharding<Long>, hashFunction: (String) -> Long = DEFAULT_HASH_FUNCTION) : AggregateIdSharding
Decorator that adapts a numeric sharding strategy for aggregate IDs using a hash function.
This class wraps a PreciseSharding
The default hash function extracts the sequence number from globally unique IDs, providing good distribution characteristics.
Example usage:
val numericSharding = ModuloSharding(4) // Shards into 4 buckets
val aggregateSharding = CosIdShardingDecorator(numericSharding)
val shard = aggregateSharding.sharding(aggregateId) // Returns "0", "1", "2", or "3"Content copied to clipboard
See also
PreciseSharding