{"_id":"@a-mehrabi/aranode-kafka-client","_rev":"1-8ad4a414d694b682e5f95b45f24d3bbd","name":"@a-mehrabi/aranode-kafka-client","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@a-mehrabi/aranode-kafka-client","version":"1.0.0","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","publishConfig":{"access":"public"},"scripts":{"build":"tsc --build","build:prod":"tsc --build","test":"jest lib/*","release":"semantic-release"},"dependencies":{"@a-mehrabi/aranode-types":"workspace:*","class-transformer":"^0.4.0","class-validator":"^0.13.1","kafkajs":"^1.15.0","reflect-metadata":"^0.1.13"},"devDependencies":{"@types/jest":"^26.0.23","jest":"26.6.3","jest-junit":"12.0.0","jest-mock-extended":"1.0.14","semantic-release":"^18.0.1","semantic-release-monorepo":"^7.0.5","ts-jest":"26.5.6","typescript":"4.2.4"},"aranode":{"version":"^0.5.0-beta"},"gitHead":"e88a63821bb3f25a024cd786b7eb6198166bd825","description":"kafka client implementation for aranode flow engine.","_id":"@a-mehrabi/aranode-kafka-client@1.0.0","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-lakb+Mm24Mt0KsVi3o1xQnmVsEZGZdsmM3iPAylr32f0W7XHCFE7QWn4Khwbn14yF+5w2I1jEoIEzoZFxvF5kw==","shasum":"a88fbadc495be736003f00797f8ca16ee1893206","tarball":"https://registry.npmjs.org/@a-mehrabi/aranode-kafka-client/-/aranode-kafka-client-1.0.0.tgz","fileCount":59,"unpackedSize":37247,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzGL6CRA9TVsSAnZWagAA5SoP/ROGwio+WM3QYa3TsFN8\n/Xz4HUkf8UZk887HGmEbYrfvxA2vP0204os4GcpobfpoajFKMSahX21cXv2r\nEkG3HI1tmFy2ELtzfErkTxFXdKd3LyHH0rVolOiIMosFMPZxi0g3Oqm6+IxG\nuANd738vNDV9WZcjQcI/WfuYsDKzAkRgsfEMNgGU7ddeZmfoEasOoqK9a3do\nCv/xU1O6m1k/Be2d04braTeeUZF5Dgfq/qdXhXBXdzxd36fFMGh0nzlEvfHn\nUWTSx7OWJiLzz9QsEhXEHqOnSmGBbnhSAq5qZ4SleQpKdSGqETwiGIecLVIW\nDe7inkXwOQhkJ8HcZxJG3P7CYfJ10dWbWyFdLDY1cHldE+s7udU1vl89jIyw\nwuUZMD5WmLCtcCSeyaAZLJ/JxscLWkfclGry30E6ziHpC7K/d4s6d01dK+Ne\nFd8tpzcAyrOqNQtiaDBfgtgMvLzlLslhxST6IrzHnXpJUG3e2L4bP3VbUgy9\naY91w2XNsV/8kc2OddWRTLrCpopUqbCttMxowDq4rdLGVcRJCFo6C/nQ9M4/\njupzaRvk5OQo/fj7jknQekUxclwiCdp3epJ93C9nd+DP2Q8fRyJhXxBso8zf\n0iI+KlamUJb/gJ+BVGq3EcMshTiEiDiHF6SQriXQ77AgR7HT1bQC1L4cxSOC\nJEDV\r\n=P5Jk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGgmHfNCfq9byEvO6JLNQY2DEeboNhfahqegrLf/5XcrAiApKBWn0j74N0oZtZ57siitkeFzuWtqW2ORkZVTejs1+Q=="}]},"_npmUser":{"name":"a-mehrabi","email":"a.mehrabi.ae@gmail.com"},"directories":{},"maintainers":[{"name":"a-mehrabi","email":"a.mehrabi.ae@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/aranode-kafka-client_1.0.0_1640784633974_0.8580366483490629"},"_hasShrinkwrap":false}},"time":{"created":"2021-12-29T13:30:33.895Z","1.0.0":"2021-12-29T13:30:34.120Z","modified":"2022-04-04T10:52:23.190Z"},"maintainers":[{"name":"a-mehrabi","email":"a.mehrabi.ae@gmail.com"}],"description":"kafka client implementation for aranode flow engine.","license":"MIT","readme":"# Kafka Client Module\n\nkafka client implementation for aranode flow engine.\n\n## Table of Contents\n\n- [Kafka Client Module](#kafka-client-module)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Kafka client config](#kafka-client-config)\n    - [Kafka Producer](#kafka-producer)\n    - [Kafka Consumer](#kafka-consumer)\n  - [API](#api)\n    - [kafkaClientConfig](#kafkaclientconfig)\n    - [kafkaProducer](#kafkaproducer)\n    - [kafkaConsumer](#kafkaconsumer)\n\n## Installation\n\nTo install this module in your aranode project,\nyou just need to add the package using following command:\n\n```bash\n$ yarn add @a-mehrabi/aranode-kafka-client\n```\n\nAfter that, when you want to use it,\nyou must include it in custom modules like the following:\n\n<sub><sup>path: .env</sub></sup>\n\n```env\nARANODE_CUSTOM_MODULES=@a-mehrabi/aranode-kafka-client\n```\n\n## Usage\n\nFor using Kafka client, you need three descriptions:\n\n1. [Kafka client config](#kafka-client-config) config description ([kafkaClientConfig](#kafkaclientconfig))\n\n2. [Kafka producer](#kafka-producer) adapter description ([kafkaProducer](#kafkaproducer))\n\n3. [Kafka consumer](#kafka-consumer) adapter description ([kafkaConsumer](#kafkaconsumer))\n\n### Kafka client config\n\nKafka Client config description enables you to define the config of the kafka client, including clientId, brokers config, etc.\n\nYou don't define configs of the producer and consumer in this config.\n\n```yaml\nversion: 1\nkind: config\nname: config-name\n\nconfig:\n  kafka:\n    clientId: client-id\n    brokers:\n      - localhost:9092\n    retry:\n      retries: 8\n      initialRetryTime: 100\n      maxRetryTime: 2\n      factor: 3\n      multiplier: 4\n```\n\n### Kafka Producer\n\nto publish messages to Kafka server you have to create a adapter description.\nkafka producer adapter description, sets a handler for specified kafka client.\n\nflow example:\n\n```yaml\nversion: 1\nkind: flow\nname: flow-name\nentryPoint: start\n\nflow:\n  start:\n    transform:\n      path: 'dist/producer-transformer.js'\n    nextNode: kaka\n\n  kafka:\n    port:\n      name: kafka-client-out-port\n      type: outbound\n    terminal: true\n```\n\nConfigs example:\n\n<sub><sup>path: adapter.yml</sub></sup>\n\n```yaml\nversion: 1\nkind: adapter\nname: adapter-name\n\nadapter:\n  producer:\n    client: kafka-client-config-name\n    topic: topic-name\n```\n\n<sub><sup>path: bind.yml</sub></sup>\n\n```yaml\nversion: 1\nkind: bindPro\nname: bind-name\n\nbind:\n  flow-name:\n    - type: outbound\n      port: port-name\n      adapter: adapter-name\n```\n\n### Kafka Consumer\n\nkafka consumer allow a group of machines or processes to coordinate access to a list of topics, distributing the load among the consumers.\n\nflow example:\n\n```yaml\nversion: 1\nkind: flow\nname: flow-name\nentryPoint: start\n\nflow:\n  start:\n    nextNode: consumeData\n\n  consumeData:\n    transform:\n      path: 'dist/consumer-transformer.js'\n    terminal: true\n```\n\nConfigs example:\n\n<sub><sup>path: adapter.yml</sub></sup>\n\n```yaml\nversion: 1\nkind: adapter\nname: consumer-adapter-name\n\nadapter:\n  consumer:\n    client: kafka-client-config-name\n    groupId: group-id\n    topic: topic-name\n    fromBeginning: true\n```\n\n<sub><sup>path: bind.yml</sub></sup>\n\n```yaml\nversion: 1\nkind: bind\nname: bind-name\n\nbind:\n  flow-name:\n    - type: inbound\n      port: port-name\n      adapter: consumer-adapter-name\n```\n\n## API\n\n### kafkaClientConfig\n\nType: config description\n\nOptions:\n\n- **clientId** (string), required\n\n  Kafka client id\n\n- **brokers** (string[]), required\n\n  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\n\n- **retry** ([k: string]: number), optional\n\n  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)\n\n  - **retries** (number), optional, default = `5`\n\n    Max number of retries per call\n\n  - **initialRetryTime** (number), optional, default = `300`\n\n    Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)\n\n  - **maxRetryTime** (number), optional, default = `30000`\n\n    Maximum wait time for a retry in milliseconds\n\n  - **factor** (number), optional, default = `0.2`\n\n    Randomization factor Name of the service that you want to load and use\n\n### kafkaProducer\n\nType: adapter description\n\nOptions:\n\n- **client** (string), required\n\n  Kafka client config name\n\n- **topic** (string), required, default = `null`\n\n  Topic name\n\n- **retry** ([k: string]: number), optional\n\n  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)\n\n  - **retries** (number), optional, default = `5`\n\n    Max number of retries per call\n\n  - **initialRetryTime** (number), optional, default = `300`\n\n    Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)\n\n  - **maxRetryTime** (number), optional, default = `30000`\n\n    Maximum wait time for a retry in milliseconds\n\n  - **factor** (number), optional, default = `0.2`\n\n    Randomization factor\n\n  - **multiplier** (number), optional, default = `2`\n\n    Exponential factor\n\n- **metadataMaxAge** (number), optional, default = `300000`\n\n  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\n\n- **allowAutoTopicCreation** (boolean), optional, default = `true`\n\n  Allow topic creation when querying metadata for non-existent topics\n\n- **idempotent** (boolean), optional, default = `false`\n\n  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.\n\n- **transactionalId** (string), optional\n\n- **transactionTimeout** (number), optional, default = `60000`\n\n  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.  \n  If this value is larger than the transaction max timeout ms setting in the broker, the request will fail with a InvalidTransactionTimeout error\n\n- **maxInFlightRequests** (number), optional, default = `null`\n\n  Max number of requests that may be in progress at any time. If falsey then no limit\n\n### kafkaConsumer\n\nType: adapter description\n\nOptions:\n\n- **client** (string), required\n\n  Kafka client config name\n\n- **groupId** (string), required\n\n  Group id\n\n- **topic** (string), required\n\n  Topic name\n\n- **fromBeginning** (boolean), required\n\n  The consumer group will use the latest committed offset when starting to fetch messages.\n  If the offset is invalid or not defined, fromBeginning defines the behavior of the consumer group.\n\n- **sessionTimeout** (number), optional, default = `30000`\n\n  The consumer timeout time described in milliseconds\n","readmeFilename":"README.md"}