@wikimedia/node-rdkafka-factory

1.1.0 • Public • Published

node-rdkafka-factory

This module contains slim Promise wrappers around node-rdkafka client classes.

Currently, only the Standard Producer API is wrapped.

Usage

const kafka = require('node-rdkafka-factory');

const rdkafka_conf = {
    'metadata.broker.list': 'localhost:9092'
};
const rdkafka_topic_conf = {};

// Create a 'GuaranteedProducer'.
const guaranteedKafkaProducer = await kafka.GuaranteedProducer.factory(
    rdkafka_conf,
    rdkafka_topic_conf
);
// This will wait for the Kafka producer to ACK before the async Promise resolves.
await guaranteedKafkaProducer.produce('mytopic', undefined, Buffer.from('my message'), undefined);


// Create a 'HastyProducer'.
const hastyKafkaProducer = await kafka.HastyProducer.factory(
    rdkafka_conf,
    rdkafka_topic_conf
);

// This will resolve as soon as node-rdkafka queues the produce request interally.
// It will not wait for the Kafka broker to receive the produce request or ACK it.
await hastyKafkaProducer.produce('mytopic', undefined, Buffer.from('my message'), undefined);

Readme

Keywords

Package Sidebar

Install

npm i @wikimedia/node-rdkafka-factory

Weekly Downloads

15

Version

1.1.0

License

Apache-2.0

Unpacked Size

11.8 kB

Total Files

7

Last publish

Collaborators

  • mvolz
  • lwatz16
  • tchin25
  • egardner
  • ottomata
  • annetee
  • jgiannelos-wmf
  • joakin
  • krinkle
  • jdforrester
  • edg2s
  • volker_e
  • catrope
  • santhosh.thottingal
  • cscott
  • subbu_ss
  • arlolra
  • jdlrobson
  • mateusbs17
  • brightbyte
  • phuedx
  • nrayio
  • jandre3000
  • sbassett29
  • nikerabbit