npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@a-mehrabi/aranode-kafka-client

v1.0.0

Published

kafka client implementation for aranode flow engine.

Downloads

3

Readme

Kafka Client Module

kafka client implementation for aranode flow engine.

Table of Contents

Installation

To install this module in your aranode project, you just need to add the package using following command:

$ yarn add @a-mehrabi/aranode-kafka-client

After that, when you want to use it, you must include it in custom modules like the following:

path: .env

ARANODE_CUSTOM_MODULES=@a-mehrabi/aranode-kafka-client

Usage

For using Kafka client, you need three descriptions:

  1. Kafka client config config description (kafkaClientConfig)

  2. Kafka producer adapter description (kafkaProducer)

  3. Kafka consumer adapter description (kafkaConsumer)

Kafka client config

Kafka Client config description enables you to define the config of the kafka client, including clientId, brokers config, etc.

You don't define configs of the producer and consumer in this config.

version: 1
kind: config
name: config-name

config:
  kafka:
    clientId: client-id
    brokers:
      - localhost:9092
    retry:
      retries: 8
      initialRetryTime: 100
      maxRetryTime: 2
      factor: 3
      multiplier: 4

Kafka Producer

to publish messages to Kafka server you have to create a adapter description. kafka producer adapter description, sets a handler for specified kafka client.

flow example:

version: 1
kind: flow
name: flow-name
entryPoint: start

flow:
  start:
    transform:
      path: 'dist/producer-transformer.js'
    nextNode: kaka

  kafka:
    port:
      name: kafka-client-out-port
      type: outbound
    terminal: true

Configs example:

path: adapter.yml

version: 1
kind: adapter
name: adapter-name

adapter:
  producer:
    client: kafka-client-config-name
    topic: topic-name

path: bind.yml

version: 1
kind: bindPro
name: bind-name

bind:
  flow-name:
    - type: outbound
      port: port-name
      adapter: adapter-name

Kafka Consumer

kafka consumer allow a group of machines or processes to coordinate access to a list of topics, distributing the load among the consumers.

flow example:

version: 1
kind: flow
name: flow-name
entryPoint: start

flow:
  start:
    nextNode: consumeData

  consumeData:
    transform:
      path: 'dist/consumer-transformer.js'
    terminal: true

Configs example:

path: adapter.yml

version: 1
kind: adapter
name: consumer-adapter-name

adapter:
  consumer:
    client: kafka-client-config-name
    groupId: group-id
    topic: topic-name
    fromBeginning: true

path: bind.yml

version: 1
kind: bind
name: bind-name

bind:
  flow-name:
    - type: inbound
      port: port-name
      adapter: consumer-adapter-name

API

kafkaClientConfig

Type: config description

Options:

  • clientId (string), required

    Kafka client id

  • brokers (string[]), required

    Kafka client must be configured with at least one broker. The brokers on the list are considered seed brokers and are only used to bootstrap the client and load initial metadata

  • retry ([k: string]: number), optional

    The retry option can be used to set the configuration of the retry mechanism, which is used to retry connections and API calls to Kafka (when using producers or consumers)

    • retries (number), optional, default = 5

      Max number of retries per call

    • initialRetryTime (number), optional, default = 300

      Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)

    • maxRetryTime (number), optional, default = 30000

      Maximum wait time for a retry in milliseconds

    • factor (number), optional, default = 0.2

      Randomization factor Name of the service that you want to load and use

kafkaProducer

Type: adapter description

Options:

  • client (string), required

    Kafka client config name

  • topic (string), required, default = null

    Topic name

  • retry ([k: string]: number), optional

    The retry option can be used to set the configuration of the retry mechanism, which is used to retry connections and API calls to Kafka (when using producers or consumers)

    • retries (number), optional, default = 5

      Max number of retries per call

    • initialRetryTime (number), optional, default = 300

      Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)

    • maxRetryTime (number), optional, default = 30000

      Maximum wait time for a retry in milliseconds

    • factor (number), optional, default = 0.2

      Randomization factor

    • multiplier (number), optional, default = 2

      Exponential factor

  • metadataMaxAge (number), optional, default = 300000

    The period of time in milliseconds after which we force a refresh of metadata even if we haven't seen any partition leadership changes to proactively discover any new brokers or partitions

  • allowAutoTopicCreation (boolean), optional, default = true

    Allow topic creation when querying metadata for non-existent topics

  • idempotent (boolean), optional, default = false

    Experimental. If enabled producer will ensure each message is written exactly once. Acks must be set to -1 ("all"). Retries will default to MAX_SAFE_INTEGER.

  • transactionalId (string), optional

  • transactionTimeout (number), optional, default = 60000

    The maximum amount of time in ms that the transaction coordinator will wait for a transaction status update from the producer before proactively aborting the ongoing transaction.
    If this value is larger than the transaction max timeout ms setting in the broker, the request will fail with a InvalidTransactionTimeout error

  • maxInFlightRequests (number), optional, default = null

    Max number of requests that may be in progress at any time. If falsey then no limit

kafkaConsumer

Type: adapter description

Options:

  • client (string), required

    Kafka client config name

  • groupId (string), required

    Group id

  • topic (string), required

    Topic name

  • fromBeginning (boolean), required

    The consumer group will use the latest committed offset when starting to fetch messages. If the offset is invalid or not defined, fromBeginning defines the behavior of the consumer group.

  • sessionTimeout (number), optional, default = 30000

    The consumer timeout time described in milliseconds