kafka-ts 0.0.1-beta → 0.0.3-beta
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/.github/workflows/release.yml +17 -0
- package/.prettierrc +3 -2
- package/LICENSE +1 -1
- package/README.md +48 -35
- package/docker-compose.yml +102 -102
- package/examples/package-lock.json +28 -27
- package/examples/package.json +12 -12
- package/examples/src/client.ts +6 -6
- package/examples/src/consumer.ts +9 -8
- package/examples/src/create-topic.ts +23 -16
- package/examples/src/producer.ts +7 -7
- package/examples/src/replicator.ts +4 -4
- package/examples/src/utils/delay.ts +1 -0
- package/examples/src/utils/json.ts +1 -1
- package/examples/tsconfig.json +2 -2
- package/package.json +21 -15
- package/src/__snapshots__/request-handler.test.ts.snap +9 -718
- package/src/api/api-versions.ts +2 -2
- package/src/api/create-topics.ts +2 -2
- package/src/api/delete-topics.ts +2 -2
- package/src/api/fetch.ts +3 -3
- package/src/api/find-coordinator.ts +2 -2
- package/src/api/heartbeat.ts +2 -2
- package/src/api/index.ts +18 -18
- package/src/api/init-producer-id.ts +2 -2
- package/src/api/join-group.ts +3 -3
- package/src/api/leave-group.ts +2 -2
- package/src/api/list-offsets.ts +3 -3
- package/src/api/metadata.ts +3 -3
- package/src/api/offset-commit.ts +2 -2
- package/src/api/offset-fetch.ts +2 -2
- package/src/api/produce.ts +3 -3
- package/src/api/sasl-authenticate.ts +2 -2
- package/src/api/sasl-handshake.ts +2 -2
- package/src/api/sync-group.ts +2 -2
- package/src/broker.ts +9 -9
- package/src/client.ts +6 -6
- package/src/{request-handler.test.ts → cluster.test.ts} +72 -69
- package/src/cluster.ts +7 -7
- package/src/connection.ts +17 -15
- package/src/consumer/consumer-group.ts +14 -14
- package/src/consumer/consumer-metadata.ts +2 -2
- package/src/consumer/consumer.ts +84 -82
- package/src/consumer/fetch-manager.ts +179 -0
- package/src/consumer/fetcher.ts +57 -0
- package/src/consumer/offset-manager.ts +6 -6
- package/src/consumer/processor.ts +47 -0
- package/src/distributors/assignments-to-replicas.test.ts +7 -7
- package/src/distributors/assignments-to-replicas.ts +1 -1
- package/src/distributors/messages-to-topic-partition-leaders.test.ts +6 -6
- package/src/index.ts +4 -3
- package/src/metadata.ts +4 -4
- package/src/producer/producer.ts +8 -8
- package/src/types.ts +2 -0
- package/src/utils/api.ts +4 -4
- package/src/utils/debug.ts +2 -2
- package/src/utils/decoder.ts +4 -4
- package/src/utils/encoder.ts +6 -6
- package/src/utils/error.ts +3 -3
- package/src/utils/retrier.ts +1 -1
- package/src/utils/tracer.ts +7 -4
- package/tsconfig.json +16 -16
- package/dist/api/api-versions.d.ts +0 -9
- package/dist/api/api-versions.js +0 -24
- package/dist/api/create-topics.d.ts +0 -38
- package/dist/api/create-topics.js +0 -53
- package/dist/api/delete-topics.d.ts +0 -18
- package/dist/api/delete-topics.js +0 -33
- package/dist/api/fetch.d.ts +0 -77
- package/dist/api/fetch.js +0 -106
- package/dist/api/find-coordinator.d.ts +0 -21
- package/dist/api/find-coordinator.js +0 -39
- package/dist/api/heartbeat.d.ts +0 -11
- package/dist/api/heartbeat.js +0 -27
- package/dist/api/index.d.ts +0 -573
- package/dist/api/index.js +0 -164
- package/dist/api/init-producer-id.d.ts +0 -13
- package/dist/api/init-producer-id.js +0 -29
- package/dist/api/join-group.d.ts +0 -34
- package/dist/api/join-group.js +0 -51
- package/dist/api/leave-group.d.ts +0 -19
- package/dist/api/leave-group.js +0 -39
- package/dist/api/list-offsets.d.ts +0 -29
- package/dist/api/list-offsets.js +0 -48
- package/dist/api/metadata.d.ts +0 -40
- package/dist/api/metadata.js +0 -58
- package/dist/api/offset-commit.d.ts +0 -28
- package/dist/api/offset-commit.js +0 -48
- package/dist/api/offset-fetch.d.ts +0 -33
- package/dist/api/offset-fetch.js +0 -57
- package/dist/api/produce.d.ts +0 -53
- package/dist/api/produce.js +0 -129
- package/dist/api/sasl-authenticate.d.ts +0 -11
- package/dist/api/sasl-authenticate.js +0 -23
- package/dist/api/sasl-handshake.d.ts +0 -6
- package/dist/api/sasl-handshake.js +0 -19
- package/dist/api/sync-group.d.ts +0 -24
- package/dist/api/sync-group.js +0 -36
- package/dist/broker.d.ts +0 -29
- package/dist/broker.js +0 -60
- package/dist/client.d.ts +0 -23
- package/dist/client.js +0 -36
- package/dist/cluster.d.ts +0 -24
- package/dist/cluster.js +0 -72
- package/dist/connection.d.ts +0 -25
- package/dist/connection.js +0 -155
- package/dist/consumer/consumer-group.d.ts +0 -36
- package/dist/consumer/consumer-group.js +0 -182
- package/dist/consumer/consumer-metadata.d.ts +0 -7
- package/dist/consumer/consumer-metadata.js +0 -14
- package/dist/consumer/consumer.d.ts +0 -37
- package/dist/consumer/consumer.js +0 -178
- package/dist/consumer/metadata.d.ts +0 -24
- package/dist/consumer/metadata.js +0 -64
- package/dist/consumer/offset-manager.d.ts +0 -22
- package/dist/consumer/offset-manager.js +0 -56
- package/dist/distributors/assignments-to-replicas.d.ts +0 -17
- package/dist/distributors/assignments-to-replicas.js +0 -60
- package/dist/distributors/assignments-to-replicas.test.d.ts +0 -1
- package/dist/distributors/assignments-to-replicas.test.js +0 -40
- package/dist/distributors/messages-to-topic-partition-leaders.d.ts +0 -17
- package/dist/distributors/messages-to-topic-partition-leaders.js +0 -15
- package/dist/distributors/messages-to-topic-partition-leaders.test.d.ts +0 -1
- package/dist/distributors/messages-to-topic-partition-leaders.test.js +0 -30
- package/dist/examples/src/replicator.js +0 -34
- package/dist/examples/src/utils/json.js +0 -5
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -19
- package/dist/metadata.d.ts +0 -24
- package/dist/metadata.js +0 -89
- package/dist/producer/producer.d.ts +0 -19
- package/dist/producer/producer.js +0 -111
- package/dist/request-handler.d.ts +0 -16
- package/dist/request-handler.js +0 -67
- package/dist/request-handler.test.d.ts +0 -1
- package/dist/request-handler.test.js +0 -340
- package/dist/src/api/api-versions.js +0 -18
- package/dist/src/api/create-topics.js +0 -46
- package/dist/src/api/delete-topics.js +0 -26
- package/dist/src/api/fetch.js +0 -95
- package/dist/src/api/find-coordinator.js +0 -34
- package/dist/src/api/heartbeat.js +0 -22
- package/dist/src/api/index.js +0 -38
- package/dist/src/api/init-producer-id.js +0 -24
- package/dist/src/api/join-group.js +0 -48
- package/dist/src/api/leave-group.js +0 -30
- package/dist/src/api/list-offsets.js +0 -39
- package/dist/src/api/metadata.js +0 -47
- package/dist/src/api/offset-commit.js +0 -39
- package/dist/src/api/offset-fetch.js +0 -44
- package/dist/src/api/produce.js +0 -119
- package/dist/src/api/sync-group.js +0 -31
- package/dist/src/broker.js +0 -35
- package/dist/src/connection.js +0 -21
- package/dist/src/consumer/consumer-group.js +0 -131
- package/dist/src/consumer/consumer.js +0 -103
- package/dist/src/consumer/metadata.js +0 -52
- package/dist/src/consumer/offset-manager.js +0 -23
- package/dist/src/index.js +0 -19
- package/dist/src/producer/producer.js +0 -84
- package/dist/src/request-handler.js +0 -57
- package/dist/src/request-handler.test.js +0 -321
- package/dist/src/types.js +0 -2
- package/dist/src/utils/api.js +0 -5
- package/dist/src/utils/decoder.js +0 -161
- package/dist/src/utils/encoder.js +0 -137
- package/dist/src/utils/error.js +0 -10
- package/dist/types.d.ts +0 -9
- package/dist/types.js +0 -2
- package/dist/utils/api.d.ts +0 -9
- package/dist/utils/api.js +0 -5
- package/dist/utils/debug.d.ts +0 -2
- package/dist/utils/debug.js +0 -11
- package/dist/utils/decoder.d.ts +0 -29
- package/dist/utils/decoder.js +0 -147
- package/dist/utils/delay.d.ts +0 -1
- package/dist/utils/delay.js +0 -5
- package/dist/utils/encoder.d.ts +0 -28
- package/dist/utils/encoder.js +0 -122
- package/dist/utils/error.d.ts +0 -11
- package/dist/utils/error.js +0 -27
- package/dist/utils/memo.d.ts +0 -1
- package/dist/utils/memo.js +0 -16
- package/dist/utils/retrier.d.ts +0 -10
- package/dist/utils/retrier.js +0 -22
- package/dist/utils/tracer.d.ts +0 -1
- package/dist/utils/tracer.js +0 -26
- package/examples/node_modules/.package-lock.json +0 -22
package/dist/api/fetch.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FETCH = void 0;
|
|
4
|
-
const api_1 = require("../utils/api");
|
|
5
|
-
const error_1 = require("../utils/error");
|
|
6
|
-
exports.FETCH = (0, api_1.createApi)({
|
|
7
|
-
apiKey: 1,
|
|
8
|
-
apiVersion: 16,
|
|
9
|
-
request: (encoder, data) => encoder
|
|
10
|
-
.writeUVarInt(0)
|
|
11
|
-
.writeInt32(data.maxWaitMs)
|
|
12
|
-
.writeInt32(data.minBytes)
|
|
13
|
-
.writeInt32(data.maxBytes)
|
|
14
|
-
.writeInt8(data.isolationLevel)
|
|
15
|
-
.writeInt32(data.sessionId)
|
|
16
|
-
.writeInt32(data.sessionEpoch)
|
|
17
|
-
.writeCompactArray(data.topics, (encoder, topic) => encoder
|
|
18
|
-
.writeUUID(topic.topicId)
|
|
19
|
-
.writeCompactArray(topic.partitions, (encoder, partition) => encoder
|
|
20
|
-
.writeInt32(partition.partition)
|
|
21
|
-
.writeInt32(partition.currentLeaderEpoch)
|
|
22
|
-
.writeInt64(partition.fetchOffset)
|
|
23
|
-
.writeInt32(partition.lastFetchedEpoch)
|
|
24
|
-
.writeInt64(partition.logStartOffset)
|
|
25
|
-
.writeInt32(partition.partitionMaxBytes)
|
|
26
|
-
.writeUVarInt(0))
|
|
27
|
-
.writeUVarInt(0))
|
|
28
|
-
.writeCompactArray(data.forgottenTopicsData, (encoder, forgottenTopic) => encoder
|
|
29
|
-
.writeUUID(forgottenTopic.topicId)
|
|
30
|
-
.writeCompactArray(forgottenTopic.partitions, (encoder, partition) => encoder.writeInt32(partition))
|
|
31
|
-
.writeUVarInt(0))
|
|
32
|
-
.writeCompactString(data.rackId)
|
|
33
|
-
.writeUVarInt(0),
|
|
34
|
-
response: (decoder) => {
|
|
35
|
-
const result = {
|
|
36
|
-
_tag: decoder.readTagBuffer(),
|
|
37
|
-
throttleTimeMs: decoder.readInt32(),
|
|
38
|
-
errorCode: decoder.readInt16(),
|
|
39
|
-
sessionId: decoder.readInt32(),
|
|
40
|
-
responses: decoder.readCompactArray((response) => ({
|
|
41
|
-
topicId: response.readUUID(),
|
|
42
|
-
partitions: response.readCompactArray((partition) => ({
|
|
43
|
-
partitionIndex: partition.readInt32(),
|
|
44
|
-
errorCode: partition.readInt16(),
|
|
45
|
-
highWatermark: partition.readInt64(),
|
|
46
|
-
lastStableOffset: partition.readInt64(),
|
|
47
|
-
logStartOffset: partition.readInt64(),
|
|
48
|
-
abortedTransactions: partition.readCompactArray((abortedTransaction) => ({
|
|
49
|
-
producerId: abortedTransaction.readInt64(),
|
|
50
|
-
firstOffset: abortedTransaction.readInt64(),
|
|
51
|
-
_tag: abortedTransaction.readTagBuffer(),
|
|
52
|
-
})),
|
|
53
|
-
preferredReadReplica: partition.readInt32(),
|
|
54
|
-
records: decodeRecords(partition),
|
|
55
|
-
_tag: partition.readTagBuffer(),
|
|
56
|
-
})),
|
|
57
|
-
_tag: response.readTagBuffer(),
|
|
58
|
-
})),
|
|
59
|
-
_tag2: decoder.readTagBuffer(),
|
|
60
|
-
};
|
|
61
|
-
if (result.errorCode)
|
|
62
|
-
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
63
|
-
result.responses.forEach((response) => {
|
|
64
|
-
response.partitions.forEach((partition) => {
|
|
65
|
-
if (partition.errorCode)
|
|
66
|
-
throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
return result;
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
const decodeRecords = (decoder) => {
|
|
73
|
-
const size = decoder.readUVarInt() - 1;
|
|
74
|
-
if (size <= 0) {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
const results = [];
|
|
78
|
-
while (decoder.getBufferLength() > decoder.getOffset() + 49) {
|
|
79
|
-
results.push({
|
|
80
|
-
baseOffset: decoder.readInt64(),
|
|
81
|
-
batchLength: decoder.readInt32(),
|
|
82
|
-
partitionLeaderEpoch: decoder.readInt32(),
|
|
83
|
-
magic: decoder.readInt8(),
|
|
84
|
-
crc: decoder.readUInt32(),
|
|
85
|
-
attributes: decoder.readInt16(),
|
|
86
|
-
lastOffsetDelta: decoder.readInt32(),
|
|
87
|
-
baseTimestamp: decoder.readInt64(),
|
|
88
|
-
maxTimestamp: decoder.readInt64(),
|
|
89
|
-
producerId: decoder.readInt64(),
|
|
90
|
-
producerEpoch: decoder.readInt16(),
|
|
91
|
-
baseSequence: decoder.readInt32(),
|
|
92
|
-
records: decoder.readRecords((record) => ({
|
|
93
|
-
attributes: record.readInt8(),
|
|
94
|
-
timestampDelta: record.readVarLong(),
|
|
95
|
-
offsetDelta: record.readVarInt(),
|
|
96
|
-
key: record.readVarIntString(),
|
|
97
|
-
value: record.readVarIntString(),
|
|
98
|
-
headers: record.readCompactArray((header) => ({
|
|
99
|
-
key: header.readVarIntString(),
|
|
100
|
-
value: header.readVarIntString(),
|
|
101
|
-
})),
|
|
102
|
-
})),
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return results;
|
|
106
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const KEY_TYPE: {
|
|
2
|
-
GROUP: number;
|
|
3
|
-
TRANSACTION: number;
|
|
4
|
-
};
|
|
5
|
-
export declare const FIND_COORDINATOR: import("../utils/api").Api<{
|
|
6
|
-
keyType: number;
|
|
7
|
-
keys: string[];
|
|
8
|
-
}, {
|
|
9
|
-
_tag: void;
|
|
10
|
-
throttleTimeMs: number;
|
|
11
|
-
coordinators: {
|
|
12
|
-
key: string | null;
|
|
13
|
-
nodeId: number;
|
|
14
|
-
host: string;
|
|
15
|
-
port: number;
|
|
16
|
-
errorCode: number;
|
|
17
|
-
errorMessage: string | null;
|
|
18
|
-
_tag: void;
|
|
19
|
-
}[];
|
|
20
|
-
_tag2: void;
|
|
21
|
-
}>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FIND_COORDINATOR = exports.KEY_TYPE = void 0;
|
|
4
|
-
const api_1 = require("../utils/api");
|
|
5
|
-
const error_1 = require("../utils/error");
|
|
6
|
-
exports.KEY_TYPE = {
|
|
7
|
-
GROUP: 0,
|
|
8
|
-
TRANSACTION: 1,
|
|
9
|
-
};
|
|
10
|
-
exports.FIND_COORDINATOR = (0, api_1.createApi)({
|
|
11
|
-
apiKey: 10,
|
|
12
|
-
apiVersion: 4,
|
|
13
|
-
request: (encoder, data) => encoder
|
|
14
|
-
.writeUVarInt(0)
|
|
15
|
-
.writeInt8(data.keyType)
|
|
16
|
-
.writeCompactArray(data.keys, (encoder, key) => encoder.writeCompactString(key))
|
|
17
|
-
.writeUVarInt(0),
|
|
18
|
-
response: (decoder) => {
|
|
19
|
-
const result = {
|
|
20
|
-
_tag: decoder.readTagBuffer(),
|
|
21
|
-
throttleTimeMs: decoder.readInt32(),
|
|
22
|
-
coordinators: decoder.readCompactArray((decoder) => ({
|
|
23
|
-
key: decoder.readCompactString(),
|
|
24
|
-
nodeId: decoder.readInt32(),
|
|
25
|
-
host: decoder.readCompactString(),
|
|
26
|
-
port: decoder.readInt32(),
|
|
27
|
-
errorCode: decoder.readInt16(),
|
|
28
|
-
errorMessage: decoder.readCompactString(),
|
|
29
|
-
_tag: decoder.readTagBuffer(),
|
|
30
|
-
})),
|
|
31
|
-
_tag2: decoder.readTagBuffer(),
|
|
32
|
-
};
|
|
33
|
-
result.coordinators.forEach((coordinator) => {
|
|
34
|
-
if (coordinator.errorCode)
|
|
35
|
-
throw new error_1.KafkaTSApiError(coordinator.errorCode, coordinator.errorMessage, result);
|
|
36
|
-
});
|
|
37
|
-
return result;
|
|
38
|
-
},
|
|
39
|
-
});
|
package/dist/api/heartbeat.d.ts
DELETED
package/dist/api/heartbeat.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HEARTBEAT = void 0;
|
|
4
|
-
const api_1 = require("../utils/api");
|
|
5
|
-
const error_1 = require("../utils/error");
|
|
6
|
-
exports.HEARTBEAT = (0, api_1.createApi)({
|
|
7
|
-
apiKey: 12,
|
|
8
|
-
apiVersion: 4,
|
|
9
|
-
request: (encoder, data) => encoder
|
|
10
|
-
.writeUVarInt(0)
|
|
11
|
-
.writeCompactString(data.groupId)
|
|
12
|
-
.writeInt32(data.generationId)
|
|
13
|
-
.writeCompactString(data.memberId)
|
|
14
|
-
.writeCompactString(data.groupInstanceId)
|
|
15
|
-
.writeUVarInt(0),
|
|
16
|
-
response: (decoder) => {
|
|
17
|
-
const result = {
|
|
18
|
-
_tag: decoder.readTagBuffer(),
|
|
19
|
-
throttleTimeMs: decoder.readInt32(),
|
|
20
|
-
errorCode: decoder.readInt16(),
|
|
21
|
-
_tag2: decoder.readTagBuffer(),
|
|
22
|
-
};
|
|
23
|
-
if (result.errorCode)
|
|
24
|
-
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
25
|
-
return result;
|
|
26
|
-
},
|
|
27
|
-
});
|