npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

busie-node-kafka

v1.0.1

Published

Node Kafka module optimized for use in Busie projects built with Node

Downloads

3

Readme

busie-node-kafka

A node module that provides an api for easily creating and interacting with Kafka Producers and Consumers.

Usage

Producer

import { Producer } from 'busie-node-kafka';
const config = {
  // Kafka Config here
  // See node-rdkafka docs for valid config
};
const onDelivery = (err, record) => {
  // some callback function to be invoked on message delivery
  // see node-rdkafka docs for usage.
};
const type = 'type'; // some arbitrary type to assign to the producer. used for error messaging and tracing.
const producer = new Producer(type, config, onDelivery);

Producing a keyed message

// producer initialization omitted for brevity
producer.produceKeyedMessage({ topic, partition, message, key, timestamp, opaque });

Note the named arguments. These arguments are required.

Producing a message

// producer initialization omitted for brevity
producer.produceMessage({ topic, partition, message });

Note the named arguments. These arguments are required

Destroying the producer

//producer initialization omitted for brevity
Producer.destroy(producer);

Consumer

import { Consumer } from 'busie-node-kafka';
const config = {
  // Kafka config here
  // see node-rdkafka docs valid config
};
const offsetConfig = {
  // KafkaConsumer offset config here
  // see node-rdkafka docs for valid offset config
};
const onData = () => {
  // some callback to be invoked on data consumption
  // see node-rdkafka for usage
};
const type = 'type'; // some arbitrary type to assign to the consumer. used for error messaging and tracing.
const consumer = new Consumer(type, config, offsetConfig, onData);

Subscribing to topics

// consumer initialization omitted for brevity
consumer.subscribe(['topic1', 'topic2']);

Consuming events

// consumer initialization omitted for brevity
// topic subscription omitted for brevity
consumer.consume();

Destroying a consumer

// consumer initialization omitted for brevity
Consumer.destroy(consumer);

Kafka

This module provides access to the base Kafka object that comes with node-rdkafka

import { Kafka } from 'busie-node-kafka';
// Access to Kafka.Producer, Kafka.KafkaConsumer, Kafka.AdminClient etc. now available