kafka-provider
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

kafka-provider

KafkaJS Facade to use in dataverse NodeJS projects

Config

Name Description
clientName The name of the Kafka client
brokers An array of Kafka brokers with their ports
connectionTimeout Timeout value (ms) for the Kafka connection. Default value is 1000ms. The package trows error if the connection takes more than this value

Usage

import KafkaClientProvider from 'kafka-provider';
import { KafkaConfig } from 'kafka-provider/src/types/kafka-config.interface';
import { Config as LoggerConfig } from 'commonjs-logger';
import {
  appName,
  kafkaBrokers,
  kafkaClientName,
  kafkaPassword,
  kafkaUserName,
  loggerLogLevel,
  loggerLogStyle,
} from '../config/config';

const config: KafkaConfig = {
  clientName: kafkaClientName,
  brokers: kafkaBrokers,
};

const loggerConfig: LoggerConfig = {
  logLevel: loggerLogLevel,
  logStyle: loggerLogStyle,
  appName: appName,
  moduleName: 'KafkaProvider',
};

const provider = new KafkaClientProvider(config, kafkaUserName, kafkaPassword, loggerConfig);

export default provider;

// Initialize connection
import kafkaClient from './providers/kafkaConnect';
await kafkaClient.initializeConnections();

// Send events
await kafkaClient.sendBatch(topicName, messages);

Package Sidebar

Install

npm i kafka-provider

Weekly Downloads

11

Version

1.0.2

License

ISC

Unpacked Size

65.6 kB

Total Files

20

Last publish

Collaborators

  • anokhi0895