5.1.3 • Published 3 months ago

@microfleet/plugin-kafka v5.1.3

Weekly downloads
26
License
MIT
Repository
github
Last release
3 months ago

Microfleet Kafka Plugin

Adds Kafka support to microfleet. Provides Stream like API for sending messages to Kafka broker.

For more information please read about node-rdkafka.

Install

yarn add @microfleet/plugin-kafka

Configuration

To make use of the plugin, adjust microfleet configuration in the following way:

exports.plugins = [
  ...,
  'kafka',
  ...
]

exports.kafka = {
  // librdkafka configuration
  // https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
  debug: 'consumer,cgrp,topic,fetch',
  'metadata.broker.list': 'kafka:9092',
  'group.id': 'test-group',
}

Interface

Microfleet Kafka Plugin extends service interface with the following methods:

async service.kafka.createReadStream({ streamOpts, conf, topic }): Readable

Initializes Kafka Consumer stream using provided params and creates a Readable stream. This is the reimplementation of the node-rdkafka.ConsumerStream stream with some addons. Extra parameters:

const streamOpts = {
  checkTopicExists: boolean, // Check whether consumed topics exist.
  stopOnPartitionsEOF: boolean, // Stop stream when all assigned partitions read.
  offsetQueryTimeout: number, // Milliseconds Timeout for Broker requests.
  offsetCommitTimeout: number, // Milliseconds to wait for offset commits received on stream close.
}

async service.kafka.createWriteStream({ streamOpts, conf, topic }): Writable

Initializes Kafka producer using provided params and creates a Writable stream. Detailed docs here - https://blizzard.github.io/node-rdkafka/current/ProducerStream.html

Parameter description

For information about parameters passed to the interface methods:

Example

producerStream = await service.kafka.createProducerStream({
  streamOptions: { objectMode: true, pollInterval: 10 },
  conf: {'group.id': 'other-group'},
})

consumerStream = await service.kafka.createConsumerStream({
  streamOptions: { topics: topic, streamAsBatch: true, fetchSize: 10 },
  conf: {
    debug: 'consumer',
    'enable.auto.commit': false,
    'client.id': 'someid',
    'group.id': 'other-group',
  },
  topic: {
    'auto.offset.reset': 'earliest', // 'earliest | latest' - earliest will start from las committed offset, latest - will start from last received message.
  }
)

// and then
producerStream.write({
  topic,
  value: Buffer.from(`message at ${Date.now()}`),
}, cb)

// or
producerStream.write(Buffer.from(`message at ${Date.now()}`), cb)

for await (const message of consumer) {
  // process message
}
5.1.3

3 months ago

5.1.2

3 months ago

5.1.1

3 months ago

5.1.0

3 months ago

5.0.5

4 months ago

5.0.4

4 months ago

5.0.3

4 months ago

5.0.2

4 months ago

5.0.1

4 months ago

5.0.0

4 months ago

4.3.0

4 months ago

4.2.14

5 months ago

4.2.13

5 months ago

4.2.9

7 months ago

4.2.10

7 months ago

4.2.11

6 months ago

4.2.12

6 months ago

4.2.2

12 months ago

4.2.5

12 months ago

4.2.4

12 months ago

4.2.7

11 months ago

4.2.6

12 months ago

4.2.8

11 months ago

4.0.0

1 year ago

4.2.0

1 year ago

2.31.0

2 years ago

2.33.0

2 years ago

2.29.0

2 years ago

2.29.2

2 years ago

2.27.2

2 years ago

2.25.0

2 years ago

2.27.0

2 years ago

2.23.0

2 years ago

2.19.2

2 years ago

2.19.0

2 years ago

2.15.4

2 years ago

2.17.0

2 years ago

2.15.2

2 years ago

2.21.0

2 years ago

2.15.0

2 years ago

2.13.2

2 years ago

2.13.0

2 years ago

2.11.0

2 years ago

2.11.8

2 years ago

2.11.6

2 years ago

2.11.4

2 years ago

2.11.2

2 years ago

2.11.10

2 years ago

2.11.12

2 years ago

2.11.14

2 years ago

2.9.0

2 years ago

2.8.1

2 years ago

2.8.0

2 years ago

2.8.3

2 years ago

2.8.2

2 years ago

2.7.1

3 years ago

2.7.0

3 years ago

2.6.5-next.57

3 years ago

2.6.5-next.56

3 years ago

2.6.5-next.51

3 years ago

2.6.6

3 years ago

2.6.5-next.49

3 years ago

2.6.5-next.46

3 years ago

2.6.5-next.39

3 years ago

2.6.5-next.35

3 years ago

2.6.5-next.31

3 years ago

2.6.5

3 years ago

2.6.4

4 years ago

2.6.3

4 years ago

2.6.2

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.3.2

4 years ago

2.4.0

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.2.0

4 years ago