Delegate PartitionerDelegate
Calculate a partition number given a partitionCount
and serialized keyData
. The topic
is also provided, but is typically not used.
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.dll
Syntax
public delegate Partition PartitionerDelegate(string topic, int partitionCount, ReadOnlySpan<byte> keyData, bool keyIsNull)
Parameters
Type | Name | Description |
---|---|---|
string | topic | The topic. |
int | partitionCount | The number of partitions in |
ReadOnlySpan<byte> | keyData | The serialized key data. |
bool | keyIsNull | Whether or not the key is null (distinguishes the null and empty case). |
Returns
Type | Description |
---|---|
Partition |
Remarks
A partitioner instance may be called in any thread at any time and may be called multiple times for the same message/key.
A partitioner:
- MUST NOT call any method on the producer instance.
- MUST NOT block or execute for prolonged periods of time.
- MUST return a value between 0 and partitionCnt-1.
- MUST NOT throw any exception.