@3g/kafka-wrapper

A lightweight Kafka wrapper that creates listeners and publisher.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@3g/kafka-wrapper
Minified + gzip package size for @3g/kafka-wrapper in KB

Readme

Kafka Wrapper

A lightweight Kafka wrapper that creates listeners and publisher.

Currently uses node-rdkafka behind the scenes.

Usage

Listener

const listener = kafkaListener({
  host: '127.0.0.1:29092',
  groupId: 'testing.123',
  topics: ['test-wrapper'],
}, (message: IMessage) => {
  console.log('here be msgs', message);
  console.log('message value', message.value.toString());
}, (err: Error) => {
  console.error('Err', err);
});

Publisher

const publisher = kafkaPublisher({
  host: '127.0.0.1:29092',
  clientId: 'testing-wrapper-publisher',
}, (err: Err) => {
  console.error('Err', err);
});

publisher.send({
  topic: 'test-wrapper',
  message: {
    stuff: 123,
  },
}).then(() => {
  console.log('Message sent successfully', i);
}).catch(err => {
  console.error('Err sending message', err);
});

Notes

Consumer Groups

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.