2.1.5 • Published 2 years ago
@invisible/kafka v2.1.5
@invisible/kafka
Usage
import { makeKafkaInstance, TOPICS } from '@invisible/kafka'
const { consumerFactory, producerFactory, start, stop } = makeKafkaInstance({
clientId: 'testy',
brokers: ['localhost:9092'],
})
consumerFactory({
topic: TOPICS.INSTANCE_UPDATED,
runEachMessage: async (args: EachMessagePayload) => {
console.log(`Instance ${message.value} just got updated.`)
}
})
const { producer } = producerFactory()
(async () => {
await start()
await producer.send({ topic: TOPICS.INSTANCE_UPDATED, messages: [ { value: Math.round(Math.random()*100) } ] })
await stop()
})()
Tips
Make sure to also set up safe-stop events:
process
.on('exit', stop)
.on('SIGINT', stop)
.on('uncaughtException', stop)
.on('unhandledRejection', stop)
2.1.4
2 years ago
2.1.5
2 years ago
2.1.3
3 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.15
4 years ago
2.0.14
4 years ago
2.0.12
5 years ago
2.0.11
5 years ago
2.0.10
5 years ago
2.0.9
5 years ago
2.0.8
5 years ago
2.0.7
5 years ago
2.0.6
6 years ago
2.0.5
6 years ago
2.0.4
6 years ago
2.0.3
6 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago