Is your feature request related to a problem? Please describe.
Our application maintains cached state for entities. We load that state when the first message arrives for an entity. The entity id is used as partition key to ensure that only one server (consumer within group) handles messages for that entity. When another consumer receives the partition we would like to remove the cached state from the server that was previously responsible for the partition.
Problem:
To calculate the partition we'd have to copy & paste the current implementation from default producer.
Describe the solution you'd like
It would be great if the producer would expose a function such as below
calculatePartition(topic:string, key: string | Buffer) : number.
The function could throw an error if the producer doesn't have the metadata available to calculate the partition.
Is your feature request related to a problem? Please describe. Our application maintains cached state for entities. We load that state when the first message arrives for an entity. The entity id is used as partition key to ensure that only one server (consumer within group) handles messages for that entity. When another consumer receives the partition we would like to remove the cached state from the server that was previously responsible for the partition. Problem: To calculate the partition we'd have to copy & paste the current implementation from default producer.
Describe the solution you'd like It would be great if the producer would expose a function such as below
calculatePartition(topic:string, key: string | Buffer) : number
. The function could throw an error if the producer doesn't have the metadata available to calculate the partition.Additional context