Publish list of object to kafka
yarn add post-json-to-kafka
# or
npm install --save post-json-to-kafka
The location of kafka can be set by the environment variable:
KAFKA_URL=localhost:9092 # default
const {sendToKafka} = require('post-json-to-kafka');
const exampleFunction = async () => {
const somethingToAddInsideEachMessage = 'what you want string, object, list, number';
const listOfJSON = [
{key: 'value', key2: 'value2'},
{key: 'value', something: 'value'}
];
await sendToKafka('topic', somethingToAddInsideEachMessage, listOfJSON)
};
exampleFunction().then(() => {console.log('Everything is sent')});
This package uses the debug package. You can configure it with environment variables:
DEBUG=post-json-to-kafka:debug # only debug messages
DEBUG=post-json-to-kafka:trace # only trace messages
DEBUG=post-json-to-kafka:* # every messages