Skip to content

Commit 47d45f2

Browse files
committed
Add documents
1 parent 3c91fd2 commit 47d45f2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

index.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ export interface TopicMetadata {
181181
numPartitions: number;
182182
}
183183

184+
/**
185+
* @callback MessageRouter
186+
* @description When producing messages to a partitioned topic, this router is used to select the
187+
* target partition for each message. The router only works when the `messageRoutingMode` is set to
188+
* `CustomPartition`. Please note that `getTopicName()` cannot be called on the `message`, otherwise
189+
* the behavior will be undefined because the topic is unknown before sending the message.
190+
* @param message The message to be routed.
191+
* @param topicMetadata Metadata for the partitioned topic the message is being routed to.
192+
* @returns {number} The index of the target partition (must be a number between 0 and
193+
* topicMetadata.numPartitions - 1).
194+
*/
184195
export type MessageRouter = (message: Message, topicMetadata: TopicMetadata) => number;
185196

186197
export interface SchemaInfo {

0 commit comments

Comments
 (0)