🚨 Shai-Hulud Strikes Again:More than 500 packages and 700+ versions compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@invisible/kafka

Package Overview
Dependencies
Maintainers
10
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@invisible/kafka

Unified package for setting up and using Kafka

latest
Source
npmnpm
Version
2.1.5
Version published
Weekly downloads
5
150%
Maintainers
10
Weekly downloads
 
Created
Source

@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)

FAQs

Package last updated on 26 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts