SuperTest -> Kafka-Penguin Readme

A readme style for kafka-penguin based of of the package, supertest: https://github.com/visionmedia/supertest

Kafka-Penguin

About

Kafka-Penguin is an easy-to-use, lightweight KafkaJS library for message processing. It provides developers with a single strategy for handling message processing failures by failing fast. For more information on KafkaJS, check out Getting Started.

Accelerated by OS Labs and developed by Ziyad El Baz, Kushal Talele, Timeo Williams and Ausar English.

WIP: This project is not ready for use as of yet

Getting Started

Install kafka-penguin as an npm module and save it to your package.json file as a development dependency:

npm install kafka-penguin

Once installed it can now be referenced by simply calling require('kafka-penguin');

Example

Kafka-penguin works with any Kafka client, here is an example with the client exported from another file:

//Import your kafkajs client from another file
const kafkaPenguin = require('kafka-penguin');
const devClient = require('./clientConfig.js')

const strategies = kafkaPenguin.failfast
// Initialize strategy-- passing in the # of retries and your kafkjs client
const newStrategy = new strategies.FailFast(2, devClient) 

//Create a wrong topic message 
const message = {
  topic: 'wrong-topic',
    messages: [
      {key: "hello",
       value: "world",
      }
    ]
}

// Initialize producer from the failfast strategy
const producer = newStrategy.producer();

producer.connect()
  .then(() => console.log('Connected!'))
  .then(() => producer.send(message))
  .catch((e: any) => console.log("error: ", e.message))

API

You may use any of the kafka-penguin methods:

.FailFast(retry, Kafka-client)

retry: Pass in the number of retries, which will be used to retry connections and API calls to Kafka (when using producers or consumers).

Kafka-client : Pass in the configured KafkaJS client w/ specified brokers, username, and password.

Last updated

Was this helpful?