kafka-crab-js 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml CHANGED
@@ -17,10 +17,11 @@ napi-derive = "2"
17
17
 
18
18
  anyhow = { version = "1.0", features = ["backtrace"] }
19
19
 
20
- rdkafka = { version = "0.33", features = [
20
+ rdkafka = { version = "0.34", features = [
21
21
  "libz-static",
22
22
  "cmake-build",
23
23
  "tokio",
24
+ "ssl",
24
25
  "ssl-vendored",
25
26
  ] }
26
27
  tokio = { version = "1", features = ["full"] }
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Kafka Crab Js
2
2
 
3
- 🚧 Project in Alpha Stage: API Subject to Breaking Changes 🚧
4
-
5
3
  Kafka-Crab-JS is a powerful Node.js library that allows developers to interact with Apache Kafka using Rust programming language, seamlessly integrated with Node.js applications. This documentation provides an overview of the Kafka-Crab-JS library, including installation instructions, usage guidelines, and examples.
6
4
 
7
5
  The plugin can be found on [npm](https://www.npmjs.com/package/kafka-crab-js) and the source code is available on [GitHub](https://github.com/inaiat/kafka-crab-js).
@@ -1,29 +1,29 @@
1
1
  /* eslint-disable no-await-in-loop */
2
2
 
3
3
  import timersPromises from 'node:timers/promises';
4
- import {Buffer} from 'node:buffer';
5
- import {nanoid} from 'nanoid';
6
- import {KafkaClient, CommitMode, PartitionPosition, ConsumerResult} from '../index.js';
4
+ import { Buffer } from 'node:buffer';
5
+ import { nanoid } from 'nanoid';
6
+ import { KafkaClient, CommitMode, PartitionPosition, ConsumerResult } from '../index.js';
7
7
 
8
8
  const kafkaClient = new KafkaClient({
9
9
  brokers: 'localhost:29092',
10
10
  clientId: 'my-js-group',
11
11
  logLevel: 'info',
12
- enableAnsiLogger: true});
12
+ });
13
13
  const topic = `topic-${nanoid()}`;
14
14
 
15
15
  const consumer = kafkaClient.createConsumer({
16
16
  topic,
17
17
  groupId: 'my-js-group',
18
- CommitMode: CommitMode.AutoCommit,
19
- offset: {position: PartitionPosition.Stored},
20
- configuration: {'auto.offset.reset': 'earliest'},
18
+ commitMode: CommitMode.AutoCommit,
19
+ offset: { position: PartitionPosition.Stored },
20
+ configuration: { 'auto.offset.reset': 'earliest' },
21
21
  retryStrategy: {
22
22
  retries: 5,
23
23
  pauseConsumerDuration: 5000,
24
24
  },
25
25
  });
26
- const producer = kafkaClient.createProducer({topic, configuration: {'message.timeout.ms': '5000'}});
26
+ const producer = kafkaClient.createProducer({ topic, configuration: { 'message.timeout.ms': '5000' } });
27
27
 
28
28
  async function produce() {
29
29
  for (let i = 0; i < 10; i++) {
@@ -31,7 +31,7 @@ async function produce() {
31
31
  const result = await producer.send(
32
32
  {
33
33
  topic,
34
- messages: [{value: Buffer.from(`{"_id":"${i}","name":"Elizeu Drummond Sample js","phone":"555"}`)}],
34
+ messages: [{ value: Buffer.from(`{"_id":"${i}","name":"Elizeu Drummond Sample js","phone":"555"}`) }],
35
35
  },
36
36
  );
37
37
  console.log('Js message sent. Offset:', result);
@@ -42,7 +42,7 @@ async function produce() {
42
42
  }
43
43
 
44
44
  async function startConsumer() {
45
- consumer.startConsumer(async (error, {value, partition, offset}) => {
45
+ consumer.startConsumer(async (error, { value, partition, offset }) => {
46
46
  if (error) {
47
47
  console.error('Js Consumer error', error);
48
48
  return;
package/index.d.ts CHANGED
@@ -101,7 +101,7 @@ export class KafkaClient {
101
101
  }
102
102
  export class ProducerHelper { }
103
103
  export class KafkaConsumer {
104
- startConsumer(callback: (err: Error | null, result: Payload) => Promise<ConsumerResult | undefined>): Promise<void>
104
+ startConsumer(callback: (error: Error | undefined, result: Payload) => Promise<ConsumerResult | undefined>): Promise<void>
105
105
  }
106
106
  export class KafkaProducer {
107
107
  send(producerRecord: ProducerRecord): Promise<Array<RecordMetadata>>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-crab-js",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -25,7 +25,7 @@
25
25
  "author": "inaiat@gmail.com",
26
26
  "homepage": "https://github.com/inaiat/kafka-crab-js.git",
27
27
  "devDependencies": {
28
- "@napi-rs/cli": "^2.16.1",
28
+ "@napi-rs/cli": "^2.16.3",
29
29
  "ava": "^5.3.1",
30
30
  "benny": "^3.7.1",
31
31
  "kafkajs": "^2.2.4",
@@ -41,7 +41,8 @@
41
41
  "xo": {
42
42
  "space": true,
43
43
  "rules": {
44
- "new-cap": "off"
44
+ "new-cap": "off",
45
+ "object-curly-spacing": "off"
45
46
  }
46
47
  },
47
48
  "scripts": {
@@ -55,8 +56,8 @@
55
56
  },
56
57
  "packageManager": "yarn@3.6.0",
57
58
  "optionalDependencies": {
58
- "kafka-crab-js-darwin-arm64": "0.2.0",
59
- "kafka-crab-js-darwin-x64": "0.2.0",
60
- "kafka-crab-js-linux-x64-gnu": "0.2.0"
59
+ "kafka-crab-js-darwin-arm64": "0.3.1",
60
+ "kafka-crab-js-darwin-x64": "0.3.1",
61
+ "kafka-crab-js-linux-x64-gnu": "0.3.1"
61
62
  }
62
63
  }
@@ -150,7 +150,7 @@ impl KafkaConsumer {
150
150
  }
151
151
 
152
152
  #[napi(
153
- ts_args_type = "callback: (err: Error | null, result: Payload) => Promise<ConsumerResult | undefined>"
153
+ ts_args_type = "callback: (error: Error | undefined, result: Payload) => Promise<ConsumerResult | undefined>"
154
154
  )]
155
155
  pub async fn start_consumer(&self, func: ThreadsafeFunction<Payload>) -> Result<()> {
156
156
  let ConsumerConfiguration { retry_strategy, .. } = self.consumer_configuration.clone();