Nepotistic Pontifex Maximus
    Wondering what’s next for npm?Check out our public roadmap! »

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

    0.2.1 • 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

    Install

    npm i @restorecommerce/kafka-client

    DownloadsWeekly Downloads

    210

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    62.5 kB

    Total Files

    15

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar