@dtu-olp-2024/kafka-nocobase
Version:
A NocoBase plugin for Apache Kafka integration, supporting message publishing, topic management, and event-driven workflows. Built for the DTU GreenHope project.
12 lines (10 loc) • 384 B
JavaScript
module.exports = ({ topic, partitionMetadata, messages, partitioner }) => {
if (partitionMetadata.length === 0) {
return {}
}
return messages.reduce((result, message) => {
const partition = partitioner({ topic, partitionMetadata, message })
const current = result[partition] || []
return Object.assign(result, { [partition]: [...current, message] })
}, {})
}