kafka-crab-js 1.1.2 → 1.3.0
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/README.md +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/js-binding.d.ts +23 -2
- package/js-binding.js +2 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ A lightweight, flexible, and reliable Kafka client for JavaScript/TypeScript. It
|
|
|
24
24
|
|
|
25
25
|
1. [Installation](#installation)
|
|
26
26
|
2. [Quick Start](#quick-start)
|
|
27
|
-
3. [Consumer Examples](#consumer-
|
|
27
|
+
3. [Consumer Examples](#basic-consumer-setup)
|
|
28
28
|
4. [Producer Examples](#producer-examples)
|
|
29
29
|
5. [Stream Processing](#stream-processing)
|
|
30
30
|
6. [Configuration](#configuration)
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ConsumerConfiguration, KafkaConfiguration, KafkaCrabError, Message, MessageProducer, OffsetModel, PartitionOffset, ProducerConfiguration, ProducerRecord, RecordMetadata, RetryStrategy, TopicPartitionConfig, } from './js-binding';
|
|
2
|
-
export { CommitMode, KafkaClientConfig, KafkaConsumer, KafkaProducer, PartitionPosition, SecurityProtocol, } from './js-binding';
|
|
1
|
+
export type { ConsumerConfiguration, KafkaConfiguration, KafkaCrabError, KafkaEvent, KafkaEventPayload, Message, MessageProducer, OffsetModel, PartitionOffset, ProducerConfiguration, ProducerRecord, RecordMetadata, RetryStrategy, TopicPartition, TopicPartitionConfig, } from './js-binding';
|
|
2
|
+
export { CommitMode, KafkaClientConfig, KafkaConsumer, KafkaEventName, KafkaProducer, PartitionPosition, SecurityProtocol, } from './js-binding';
|
|
3
3
|
export { KafkaClient } from './kafka-client';
|
|
4
4
|
export { KafkaStreamReadable } from './kafka-stream-readable';
|
package/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KafkaStreamReadable = exports.KafkaClient = exports.SecurityProtocol = exports.PartitionPosition = exports.KafkaProducer = exports.KafkaConsumer = exports.KafkaClientConfig = exports.CommitMode = void 0;
|
|
3
|
+
exports.KafkaStreamReadable = exports.KafkaClient = exports.SecurityProtocol = exports.PartitionPosition = exports.KafkaProducer = exports.KafkaEventName = exports.KafkaConsumer = exports.KafkaClientConfig = exports.CommitMode = void 0;
|
|
4
4
|
var js_binding_1 = require("./js-binding");
|
|
5
5
|
Object.defineProperty(exports, "CommitMode", { enumerable: true, get: function () { return js_binding_1.CommitMode; } });
|
|
6
6
|
Object.defineProperty(exports, "KafkaClientConfig", { enumerable: true, get: function () { return js_binding_1.KafkaClientConfig; } });
|
|
7
7
|
Object.defineProperty(exports, "KafkaConsumer", { enumerable: true, get: function () { return js_binding_1.KafkaConsumer; } });
|
|
8
|
+
Object.defineProperty(exports, "KafkaEventName", { enumerable: true, get: function () { return js_binding_1.KafkaEventName; } });
|
|
8
9
|
Object.defineProperty(exports, "KafkaProducer", { enumerable: true, get: function () { return js_binding_1.KafkaProducer; } });
|
|
9
10
|
Object.defineProperty(exports, "PartitionPosition", { enumerable: true, get: function () { return js_binding_1.PartitionPosition; } });
|
|
10
11
|
Object.defineProperty(exports, "SecurityProtocol", { enumerable: true, get: function () { return js_binding_1.SecurityProtocol; } });
|
package/js-binding.d.ts
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
+
export interface KafkaEventPayload {
|
|
7
|
+
action?: string
|
|
8
|
+
tpl: Array<TopicPartition>
|
|
9
|
+
error?: string
|
|
10
|
+
}
|
|
11
|
+
export enum KafkaEventName {
|
|
12
|
+
PreRebalance = 'PreRebalance',
|
|
13
|
+
PostRebalance = 'PostRebalance',
|
|
14
|
+
CommitCallback = 'CommitCallback'
|
|
15
|
+
}
|
|
16
|
+
export interface KafkaEvent {
|
|
17
|
+
name: KafkaEventName
|
|
18
|
+
payload: KafkaEventPayload
|
|
19
|
+
}
|
|
6
20
|
export interface RetryStrategy {
|
|
7
21
|
retries: number
|
|
8
22
|
retryTopic?: string
|
|
@@ -25,7 +39,8 @@ export interface ConsumerConfiguration {
|
|
|
25
39
|
export enum PartitionPosition {
|
|
26
40
|
Beginning = 'Beginning',
|
|
27
41
|
End = 'End',
|
|
28
|
-
Stored = 'Stored'
|
|
42
|
+
Stored = 'Stored',
|
|
43
|
+
Invalid = 'Invalid'
|
|
29
44
|
}
|
|
30
45
|
export interface OffsetModel {
|
|
31
46
|
offset?: number
|
|
@@ -40,6 +55,10 @@ export interface TopicPartitionConfig {
|
|
|
40
55
|
allOffsets?: OffsetModel
|
|
41
56
|
partitionOffset?: Array<PartitionOffset>
|
|
42
57
|
}
|
|
58
|
+
export interface TopicPartition {
|
|
59
|
+
topic: string
|
|
60
|
+
partitionOffset: Array<PartitionOffset>
|
|
61
|
+
}
|
|
43
62
|
export enum SecurityProtocol {
|
|
44
63
|
Plaintext = 'Plaintext',
|
|
45
64
|
Ssl = 'Ssl',
|
|
@@ -88,12 +107,14 @@ export interface ProducerConfiguration {
|
|
|
88
107
|
configuration?: Record<string, string>
|
|
89
108
|
}
|
|
90
109
|
export declare class KafkaConsumer {
|
|
110
|
+
onEvents(callback: (error: Error | undefined, event: KafkaEvent) => void): void
|
|
91
111
|
subscribe(topicConfigs: string | Array<TopicPartitionConfig>): Promise<void>
|
|
92
112
|
pause(): void
|
|
93
113
|
resume(): void
|
|
94
114
|
unsubscribe(): void
|
|
95
|
-
|
|
115
|
+
disconnect(): Promise<void>
|
|
96
116
|
seek(topic: string, partition: number, offsetModel: OffsetModel, timeout?: number | undefined | null): void
|
|
117
|
+
assignment(): Array<TopicPartition>
|
|
97
118
|
recv(): Promise<Message | null>
|
|
98
119
|
commit(topic: string, partition: number, offset: number, commit: CommitMode): void
|
|
99
120
|
}
|
package/js-binding.js
CHANGED
|
@@ -310,8 +310,9 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { KafkaConsumer, CommitMode, PartitionPosition, SecurityProtocol, KafkaClientConfig, KafkaProducer } = nativeBinding
|
|
313
|
+
const { KafkaEventName, KafkaConsumer, CommitMode, PartitionPosition, SecurityProtocol, KafkaClientConfig, KafkaProducer } = nativeBinding
|
|
314
314
|
|
|
315
|
+
module.exports.KafkaEventName = KafkaEventName
|
|
315
316
|
module.exports.KafkaConsumer = KafkaConsumer
|
|
316
317
|
module.exports.CommitMode = CommitMode
|
|
317
318
|
module.exports.PartitionPosition = PartitionPosition
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kafka-crab-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"module": "commonjs",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@faker-js/faker": "9.3.0",
|
|
44
44
|
"@napi-rs/cli": "^2.18.4",
|
|
45
|
-
"@types/node": "22.10.
|
|
45
|
+
"@types/node": "22.10.5",
|
|
46
46
|
"ava": "6.2.0",
|
|
47
47
|
"dprint": "^0.48.0",
|
|
48
48
|
"nanoid": "5.0.9",
|
|
49
|
-
"typescript": "5.7.
|
|
49
|
+
"typescript": "5.7.3",
|
|
50
50
|
"copyfiles": "^2.4.1",
|
|
51
51
|
"@types/copyfiles": "^2.4.4",
|
|
52
52
|
"rimraf": "^6.0.1"
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"version": "napi version",
|
|
66
66
|
"fmt": "dprint fmt"
|
|
67
67
|
},
|
|
68
|
-
"packageManager": "pnpm@9.15.
|
|
68
|
+
"packageManager": "pnpm@9.15.3",
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"kafka-crab-js-darwin-arm64": "1.
|
|
71
|
-
"kafka-crab-js-darwin-x64": "1.
|
|
72
|
-
"kafka-crab-js-linux-x64-gnu": "1.
|
|
70
|
+
"kafka-crab-js-darwin-arm64": "1.3.0",
|
|
71
|
+
"kafka-crab-js-darwin-x64": "1.3.0",
|
|
72
|
+
"kafka-crab-js-linux-x64-gnu": "1.3.0"
|
|
73
73
|
}
|
|
74
74
|
}
|