Package io.namastack.outbox.partition
Object PartitionHasher
-
- All Implemented Interfaces:
public class PartitionHasherUtility for calculating partition assignments using consistent hashing.
This class provides deterministic partition assignment for aggregate IDs, ensuring that the same aggregate ID always maps to the same partition.
- Since:
0.2.0
Roland Beisel
-
-
Field Summary
Fields Modifier and Type Field Description public final static IntegerTOTAL_PARTITIONSpublic final static PartitionHasherINSTANCE
-
Method Summary
Modifier and Type Method Description final IntegergetPartitionForAggregate(String aggregateId)Calculates the partition number for a given aggregate ID. -
-
Method Detail
-
getPartitionForAggregate
final Integer getPartitionForAggregate(String aggregateId)
Calculates the partition number for a given aggregate ID.
Uses consistent hashing to ensure the same aggregate ID always maps to the same partition, regardless of the number of instances.
- Parameters:
aggregateId- The aggregate ID to calculate partition for- Returns:
Partition number between 0 and TOTAL_PARTITIONS-1
-
-
-
-