1.4.1 • Published 4 years ago

@optum/knack-consumer-client v1.4.1

Weekly downloads
10
License
Apache-2.0
Repository
github
Last release
4 years ago

Usage

first things first...

$ npm i @optum/knack-consumer-client

options

  • subscriptions: Array array of subscription objects
    • subscription: [Object] consumer subscription info
      • topic: [String] name of topic
      • handler: [Function] handler for each record consumed
  • consumerConfig: [Object] librd consumer config
  • topicConfig: [Object] librd topic config
  • flowMode: [Boolean] run flow mode or control message intake cadence
  • logger: [Object] logger object with trace, debug, info, error methods
  • srOptions: [Object]: options to pass to knack-sr

Examples

const knackConsumerClient = require('@optum/knack-consumer-client');

const consumerConfig = {
    'client.id': 'my-kafka-client-v1',
    'group.id': 'my-kafka-group-v1',
    'metadata.broker.list': 'localhost:9092',
    'socket.keepalive.enable': true,
    'enable.auto.commit': true
};

const topicConfig = {
    'auto.offset.reset': 'earliest',
    // eslint-disable-next-line camelcase
    event_cb: () => {}
};

const topic = 'knack-test-topic-v1';

const handler = ({key, value, topic, timestamp}) => {
    // do stuff with record
};

// connect consumer with options
const testConsumer = await knackConsumerClient.connect({
    subscriptions: [{
        topic,
        handler
    }],
    consumerConfig,
    topicConfig,
    srOptions: {
        url: 'http://localhost:8081'
    }
});

process.on('SIGINT', async () => {
    await knackConsumerClient.disconnect();
});
1.4.1

4 years ago

1.4.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.4.0

4 years ago

0.3.1

4 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago