@restorecommerce/kafka-client
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

kafka-client

VersionBuild StatusDependenciesCoverage Status

A Node.js client for Apache Kafka based on kafka-node. Event messages structures are defined using Protocol Buffers with message encoding/decoding being achieved using protobufjs.

With this module, it is possible to have a fine grained control over which Kafka topics and event names the client can subscribe to. There could be multiple event names associated for the same message. Internally message events are emitted to local listeners using Node.js Events, which decode protobuf messages and execute the intended listeners.

This client includes a Provider object, which packages events and distributes them to the respective listeners. Currently, the following event providers are implemented:

  • Kafka
  • Local (in-process events, designed for testing)

When subscribing to a given event name, options can be passed. Currently, the supported subscription options are:

  • startingOffset - value for the starting offset to process messages; default is -1 (latest offset);
  • queue - a boolean flag; if set to true, messages are queued and processed synchronously;
  • forceOffset - a boolean flag; if set to true, startingOffset is considered above any other provided offset or configuration parameter.

Development

Tests

See tests. To execute the tests a set of backing services are needed. Refer to System repository to start the backing-services before running the tests.

  • To run tests
npm run test

Usage

  • Install dependencies
npm install
  • Build
# compile the code
npm run build

Package Sidebar

Install

npm i @restorecommerce/kafka-client

Weekly Downloads

527

Version

1.2.5

License

MIT

Unpacked Size

120 kB

Total Files

21

Last publish

Collaborators

  • vanthome
  • akumarnpm
  • dani723
  • vilsol
  • radu1990