kafka-ts 1.3.1-beta.1 → 1.3.1-beta.2
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 +7 -7
- package/dist/api/alter-configs.d.ts +26 -0
- package/dist/api/alter-configs.js +33 -0
- package/dist/api/api-versions.d.ts +5 -2
- package/dist/api/api-versions.js +13 -0
- package/dist/api/create-topics.d.ts +14 -12
- package/dist/api/create-topics.js +104 -12
- package/dist/api/delete-topics.d.ts +10 -8
- package/dist/api/delete-topics.js +61 -7
- package/dist/api/fetch.d.ts +15 -12
- package/dist/api/fetch.js +131 -13
- package/dist/api/find-coordinator.d.ts +9 -7
- package/dist/api/find-coordinator.js +63 -5
- package/dist/api/heartbeat.d.ts +7 -5
- package/dist/api/heartbeat.js +42 -4
- package/dist/api/index.d.ts +47 -118
- package/dist/api/init-producer-id.d.ts +7 -5
- package/dist/api/init-producer-id.js +53 -9
- package/dist/api/join-group.d.ts +9 -7
- package/dist/api/join-group.js +95 -6
- package/dist/api/leave-group.d.ts +8 -6
- package/dist/api/leave-group.js +49 -6
- package/dist/api/list-offsets.d.ts +9 -7
- package/dist/api/list-offsets.js +85 -8
- package/dist/api/metadata.d.ts +10 -9
- package/dist/api/metadata.js +109 -8
- package/dist/api/offset-commit.d.ts +10 -8
- package/dist/api/offset-commit.js +88 -8
- package/dist/api/offset-fetch.d.ts +11 -9
- package/dist/api/offset-fetch.js +94 -9
- package/dist/api/produce.d.ts +8 -10
- package/dist/api/produce.js +132 -38
- package/dist/api/sasl-authenticate.d.ts +8 -6
- package/dist/api/sasl-authenticate.js +43 -3
- package/dist/api/sasl-handshake.d.ts +7 -4
- package/dist/api/sasl-handshake.js +10 -0
- package/dist/api/sync-group.d.ts +7 -5
- package/dist/api/sync-group.js +62 -5
- package/dist/broker.js +6 -5
- package/dist/cluster.test.js +17 -14
- package/dist/connection.d.ts +11 -1
- package/dist/connection.js +27 -2
- package/dist/consumer/consumer.js +13 -9
- package/dist/consumer/metadata.d.ts +24 -0
- package/dist/consumer/metadata.js +64 -0
- package/dist/distributors/messages-to-topic-partition-leaders.d.ts +17 -0
- package/dist/distributors/messages-to-topic-partition-leaders.js +15 -0
- package/dist/distributors/messages-to-topic-partition-leaders.test.d.ts +1 -0
- package/dist/distributors/messages-to-topic-partition-leaders.test.js +30 -0
- package/dist/examples/src/replicator.js +34 -0
- package/dist/examples/src/utils/json.js +5 -0
- package/dist/request-handler.d.ts +16 -0
- package/dist/request-handler.js +67 -0
- package/dist/request-handler.test.d.ts +1 -0
- package/dist/request-handler.test.js +340 -0
- package/dist/src/api/api-versions.js +18 -0
- package/dist/src/api/create-topics.js +46 -0
- package/dist/src/api/delete-topics.js +26 -0
- package/dist/src/api/fetch.js +95 -0
- package/dist/src/api/find-coordinator.js +34 -0
- package/dist/src/api/heartbeat.js +22 -0
- package/dist/src/api/index.js +38 -0
- package/dist/src/api/init-producer-id.js +24 -0
- package/dist/src/api/join-group.js +48 -0
- package/dist/src/api/leave-group.js +30 -0
- package/dist/src/api/list-offsets.js +39 -0
- package/dist/src/api/metadata.js +47 -0
- package/dist/src/api/offset-commit.js +39 -0
- package/dist/src/api/offset-fetch.js +44 -0
- package/dist/src/api/produce.js +119 -0
- package/dist/src/api/sync-group.js +31 -0
- package/dist/src/broker.js +35 -0
- package/dist/src/connection.js +21 -0
- package/dist/src/consumer/consumer-group.js +131 -0
- package/dist/src/consumer/consumer.js +103 -0
- package/dist/src/consumer/metadata.js +52 -0
- package/dist/src/consumer/offset-manager.js +23 -0
- package/dist/src/index.js +19 -0
- package/dist/src/producer/producer.js +84 -0
- package/dist/src/request-handler.js +57 -0
- package/dist/src/request-handler.test.js +321 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils/api.js +5 -0
- package/dist/src/utils/decoder.js +161 -0
- package/dist/src/utils/encoder.js +137 -0
- package/dist/src/utils/error.js +10 -0
- package/dist/utils/api.d.ts +4 -1
- package/dist/utils/cached.d.ts +3 -0
- package/dist/utils/cached.js +19 -0
- package/dist/utils/debug.d.ts +2 -0
- package/dist/utils/debug.js +11 -0
- package/dist/utils/decoder.d.ts +2 -2
- package/dist/utils/decoder.js +14 -1
- package/dist/utils/encoder.d.ts +1 -0
- package/dist/utils/encoder.js +14 -0
- package/dist/utils/lock.d.ts +8 -0
- package/dist/utils/lock.js +44 -0
- package/dist/utils/memo.d.ts +1 -0
- package/dist/utils/memo.js +16 -0
- package/dist/utils/mutex.d.ts +3 -0
- package/dist/utils/mutex.js +32 -0
- package/package.json +1 -1
package/dist/api/leave-group.js
CHANGED
|
@@ -3,30 +3,73 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LEAVE_GROUP = void 0;
|
|
4
4
|
const api_1 = require("../utils/api");
|
|
5
5
|
const error_1 = require("../utils/error");
|
|
6
|
+
/*
|
|
7
|
+
LeaveGroup Request (Version: 0) => group_id member_id
|
|
8
|
+
group_id => STRING
|
|
9
|
+
member_id => STRING
|
|
10
|
+
|
|
11
|
+
LeaveGroup Response (Version: 0) => error_code
|
|
12
|
+
error_code => INT16
|
|
13
|
+
*/
|
|
14
|
+
const LEAVE_GROUP_V0 = (0, api_1.createApi)({
|
|
15
|
+
apiKey: 13,
|
|
16
|
+
apiVersion: 0,
|
|
17
|
+
requestHeaderVersion: 1,
|
|
18
|
+
responseHeaderVersion: 0,
|
|
19
|
+
request: (encoder, body) => encoder.writeString(body.groupId).writeString(body.members[0].memberId),
|
|
20
|
+
response: (decoder) => {
|
|
21
|
+
const result = {
|
|
22
|
+
throttleTimeMs: 0,
|
|
23
|
+
errorCode: decoder.readInt16(),
|
|
24
|
+
members: [],
|
|
25
|
+
tags: {},
|
|
26
|
+
};
|
|
27
|
+
if (result.errorCode)
|
|
28
|
+
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
29
|
+
return result;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
/*
|
|
33
|
+
LeaveGroup Request (Version: 5) => group_id [members] _tagged_fields
|
|
34
|
+
group_id => COMPACT_STRING
|
|
35
|
+
members => member_id group_instance_id reason _tagged_fields
|
|
36
|
+
member_id => COMPACT_STRING
|
|
37
|
+
group_instance_id => COMPACT_NULLABLE_STRING
|
|
38
|
+
reason => COMPACT_NULLABLE_STRING
|
|
39
|
+
|
|
40
|
+
LeaveGroup Response (Version: 5) => throttle_time_ms error_code [members] _tagged_fields
|
|
41
|
+
throttle_time_ms => INT32
|
|
42
|
+
error_code => INT16
|
|
43
|
+
members => member_id group_instance_id error_code _tagged_fields
|
|
44
|
+
member_id => COMPACT_STRING
|
|
45
|
+
group_instance_id => COMPACT_NULLABLE_STRING
|
|
46
|
+
error_code => INT16
|
|
47
|
+
*/
|
|
6
48
|
exports.LEAVE_GROUP = (0, api_1.createApi)({
|
|
7
49
|
apiKey: 13,
|
|
8
50
|
apiVersion: 5,
|
|
51
|
+
fallback: LEAVE_GROUP_V0,
|
|
52
|
+
requestHeaderVersion: 2,
|
|
53
|
+
responseHeaderVersion: 1,
|
|
9
54
|
request: (encoder, body) => encoder
|
|
10
|
-
.writeUVarInt(0)
|
|
11
55
|
.writeCompactString(body.groupId)
|
|
12
56
|
.writeCompactArray(body.members, (encoder, member) => encoder
|
|
13
57
|
.writeCompactString(member.memberId)
|
|
14
58
|
.writeCompactString(member.groupInstanceId)
|
|
15
59
|
.writeCompactString(member.reason)
|
|
16
|
-
.
|
|
17
|
-
.
|
|
60
|
+
.writeTagBuffer())
|
|
61
|
+
.writeTagBuffer(),
|
|
18
62
|
response: (decoder) => {
|
|
19
63
|
const result = {
|
|
20
|
-
_tag: decoder.readTagBuffer(),
|
|
21
64
|
throttleTimeMs: decoder.readInt32(),
|
|
22
65
|
errorCode: decoder.readInt16(),
|
|
23
66
|
members: decoder.readCompactArray((decoder) => ({
|
|
24
67
|
memberId: decoder.readCompactString(),
|
|
25
68
|
groupInstanceId: decoder.readCompactString(),
|
|
26
69
|
errorCode: decoder.readInt16(),
|
|
27
|
-
|
|
70
|
+
tags: decoder.readTagBuffer(),
|
|
28
71
|
})),
|
|
29
|
-
|
|
72
|
+
tags: decoder.readTagBuffer(),
|
|
30
73
|
};
|
|
31
74
|
if (result.errorCode)
|
|
32
75
|
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IsolationLevel } from './fetch';
|
|
2
|
-
|
|
2
|
+
type ListOffsetsRequest = {
|
|
3
3
|
replicaId: number;
|
|
4
4
|
isolationLevel: IsolationLevel;
|
|
5
5
|
topics: {
|
|
@@ -10,8 +10,8 @@ export declare const LIST_OFFSETS: import("../utils/api").Api<{
|
|
|
10
10
|
timestamp: bigint;
|
|
11
11
|
}[];
|
|
12
12
|
}[];
|
|
13
|
-
}
|
|
14
|
-
|
|
13
|
+
};
|
|
14
|
+
type ListOffsetsResponse = {
|
|
15
15
|
throttleTimeMs: number;
|
|
16
16
|
topics: {
|
|
17
17
|
name: string;
|
|
@@ -21,9 +21,11 @@ export declare const LIST_OFFSETS: import("../utils/api").Api<{
|
|
|
21
21
|
timestamp: bigint;
|
|
22
22
|
offset: bigint;
|
|
23
23
|
leaderEpoch: number;
|
|
24
|
-
|
|
24
|
+
tags: Record<number, Buffer>;
|
|
25
25
|
}[];
|
|
26
|
-
|
|
26
|
+
tags: Record<number, Buffer>;
|
|
27
27
|
}[];
|
|
28
|
-
|
|
29
|
-
}
|
|
28
|
+
tags: Record<number, Buffer>;
|
|
29
|
+
};
|
|
30
|
+
export declare const LIST_OFFSETS: import("../utils/api").Api<ListOffsetsRequest, ListOffsetsResponse>;
|
|
31
|
+
export {};
|
package/dist/api/list-offsets.js
CHANGED
|
@@ -3,11 +3,89 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LIST_OFFSETS = void 0;
|
|
4
4
|
const api_1 = require("../utils/api");
|
|
5
5
|
const error_1 = require("../utils/error");
|
|
6
|
+
/*
|
|
7
|
+
ListOffsets Request (Version: 1) => replica_id [topics]
|
|
8
|
+
replica_id => INT32
|
|
9
|
+
topics => name [partitions]
|
|
10
|
+
name => STRING
|
|
11
|
+
partitions => partition_index timestamp
|
|
12
|
+
partition_index => INT32
|
|
13
|
+
timestamp => INT64
|
|
14
|
+
|
|
15
|
+
ListOffsets Response (Version: 1) => [topics]
|
|
16
|
+
topics => name [partitions]
|
|
17
|
+
name => STRING
|
|
18
|
+
partitions => partition_index error_code timestamp offset
|
|
19
|
+
partition_index => INT32
|
|
20
|
+
error_code => INT16
|
|
21
|
+
timestamp => INT64
|
|
22
|
+
offset => INT64
|
|
23
|
+
*/
|
|
24
|
+
const LIST_OFFSETS_V1 = (0, api_1.createApi)({
|
|
25
|
+
apiKey: 2,
|
|
26
|
+
apiVersion: 1,
|
|
27
|
+
requestHeaderVersion: 1,
|
|
28
|
+
responseHeaderVersion: 0,
|
|
29
|
+
request: (encoder, data) => encoder
|
|
30
|
+
.writeInt32(data.replicaId)
|
|
31
|
+
.writeArray(data.topics, (encoder, topic) => encoder
|
|
32
|
+
.writeString(topic.name)
|
|
33
|
+
.writeArray(topic.partitions, (encoder, partition) => encoder.writeInt32(partition.partitionIndex).writeInt64(partition.timestamp))),
|
|
34
|
+
response: (decoder) => {
|
|
35
|
+
const result = {
|
|
36
|
+
throttleTimeMs: 0,
|
|
37
|
+
topics: decoder.readArray((decoder) => ({
|
|
38
|
+
name: decoder.readString(),
|
|
39
|
+
partitions: decoder.readArray((decoder) => ({
|
|
40
|
+
partitionIndex: decoder.readInt32(),
|
|
41
|
+
errorCode: decoder.readInt16(),
|
|
42
|
+
timestamp: decoder.readInt64(),
|
|
43
|
+
offset: decoder.readInt64(),
|
|
44
|
+
leaderEpoch: -1,
|
|
45
|
+
tags: {},
|
|
46
|
+
})),
|
|
47
|
+
tags: {},
|
|
48
|
+
})),
|
|
49
|
+
tags: {},
|
|
50
|
+
};
|
|
51
|
+
result.topics.forEach((topic) => {
|
|
52
|
+
topic.partitions.forEach((partition) => {
|
|
53
|
+
if (partition.errorCode)
|
|
54
|
+
throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
return result;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
/*
|
|
61
|
+
ListOffsets Request (Version: 8) => replica_id isolation_level [topics] _tagged_fields
|
|
62
|
+
replica_id => INT32
|
|
63
|
+
isolation_level => INT8
|
|
64
|
+
topics => name [partitions] _tagged_fields
|
|
65
|
+
name => COMPACT_STRING
|
|
66
|
+
partitions => partition_index current_leader_epoch timestamp _tagged_fields
|
|
67
|
+
partition_index => INT32
|
|
68
|
+
current_leader_epoch => INT32
|
|
69
|
+
timestamp => INT64
|
|
70
|
+
|
|
71
|
+
ListOffsets Response (Version: 8) => throttle_time_ms [topics] _tagged_fields
|
|
72
|
+
throttle_time_ms => INT32
|
|
73
|
+
topics => name [partitions] _tagged_fields
|
|
74
|
+
name => COMPACT_STRING
|
|
75
|
+
partitions => partition_index error_code timestamp offset leader_epoch _tagged_fields
|
|
76
|
+
partition_index => INT32
|
|
77
|
+
error_code => INT16
|
|
78
|
+
timestamp => INT64
|
|
79
|
+
offset => INT64
|
|
80
|
+
leader_epoch => INT32
|
|
81
|
+
*/
|
|
6
82
|
exports.LIST_OFFSETS = (0, api_1.createApi)({
|
|
7
83
|
apiKey: 2,
|
|
8
84
|
apiVersion: 8,
|
|
85
|
+
fallback: LIST_OFFSETS_V1,
|
|
86
|
+
requestHeaderVersion: 2,
|
|
87
|
+
responseHeaderVersion: 1,
|
|
9
88
|
request: (encoder, data) => encoder
|
|
10
|
-
.writeUVarInt(0)
|
|
11
89
|
.writeInt32(data.replicaId)
|
|
12
90
|
.writeInt8(data.isolationLevel)
|
|
13
91
|
.writeCompactArray(data.topics, (encoder, topic) => encoder
|
|
@@ -16,12 +94,11 @@ exports.LIST_OFFSETS = (0, api_1.createApi)({
|
|
|
16
94
|
.writeInt32(partition.partitionIndex)
|
|
17
95
|
.writeInt32(partition.currentLeaderEpoch)
|
|
18
96
|
.writeInt64(partition.timestamp)
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.
|
|
97
|
+
.writeTagBuffer())
|
|
98
|
+
.writeTagBuffer())
|
|
99
|
+
.writeTagBuffer(),
|
|
22
100
|
response: (decoder) => {
|
|
23
101
|
const result = {
|
|
24
|
-
_tag: decoder.readTagBuffer(),
|
|
25
102
|
throttleTimeMs: decoder.readInt32(),
|
|
26
103
|
topics: decoder.readCompactArray((decoder) => ({
|
|
27
104
|
name: decoder.readCompactString(),
|
|
@@ -31,11 +108,11 @@ exports.LIST_OFFSETS = (0, api_1.createApi)({
|
|
|
31
108
|
timestamp: decoder.readInt64(),
|
|
32
109
|
offset: decoder.readInt64(),
|
|
33
110
|
leaderEpoch: decoder.readInt32(),
|
|
34
|
-
|
|
111
|
+
tags: decoder.readTagBuffer(),
|
|
35
112
|
})),
|
|
36
|
-
|
|
113
|
+
tags: decoder.readTagBuffer(),
|
|
37
114
|
})),
|
|
38
|
-
|
|
115
|
+
tags: decoder.readTagBuffer(),
|
|
39
116
|
};
|
|
40
117
|
result.topics.forEach((topic) => {
|
|
41
118
|
topic.partitions.forEach((partition) => {
|
package/dist/api/metadata.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const METADATA: import("../utils/api").Api<{
|
|
1
|
+
type MetadataRequest = {
|
|
3
2
|
topics?: {
|
|
4
3
|
id: string | null;
|
|
5
4
|
name: string;
|
|
6
5
|
}[] | null;
|
|
7
6
|
allowTopicAutoCreation?: boolean;
|
|
8
7
|
includeTopicAuthorizedOperations?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
8
|
+
};
|
|
9
|
+
type MetadataResponse = {
|
|
11
10
|
throttleTimeMs: number;
|
|
12
11
|
brokers: {
|
|
13
12
|
nodeId: number;
|
|
14
13
|
host: string;
|
|
15
14
|
port: number;
|
|
16
15
|
rack: string | null;
|
|
17
|
-
_tag: void;
|
|
18
16
|
}[];
|
|
19
17
|
clusterId: string | null;
|
|
20
18
|
controllerId: number;
|
|
@@ -31,10 +29,13 @@ export declare const METADATA: import("../utils/api").Api<{
|
|
|
31
29
|
replicaNodes: number[];
|
|
32
30
|
isrNodes: number[];
|
|
33
31
|
offlineReplicas: number[];
|
|
34
|
-
|
|
32
|
+
tags: Record<number, Buffer>;
|
|
35
33
|
}[];
|
|
36
34
|
topicAuthorizedOperations: number;
|
|
37
|
-
|
|
35
|
+
tags: Record<number, Buffer>;
|
|
38
36
|
}[];
|
|
39
|
-
|
|
40
|
-
}
|
|
37
|
+
tags: Record<number, Buffer>;
|
|
38
|
+
};
|
|
39
|
+
export type Metadata = MetadataResponse;
|
|
40
|
+
export declare const METADATA: import("../utils/api").Api<MetadataRequest, MetadataResponse>;
|
|
41
|
+
export {};
|
package/dist/api/metadata.js
CHANGED
|
@@ -3,25 +3,126 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.METADATA = void 0;
|
|
4
4
|
const api_1 = require("../utils/api");
|
|
5
5
|
const error_1 = require("../utils/error");
|
|
6
|
+
/*
|
|
7
|
+
Metadata Request (Version: 0) => [topics]
|
|
8
|
+
topics => name
|
|
9
|
+
name => STRING
|
|
10
|
+
|
|
11
|
+
Metadata Response (Version: 0) => [brokers] [topics]
|
|
12
|
+
brokers => node_id host port
|
|
13
|
+
node_id => INT32
|
|
14
|
+
host => STRING
|
|
15
|
+
port => INT32
|
|
16
|
+
topics => error_code name [partitions]
|
|
17
|
+
error_code => INT16
|
|
18
|
+
name => STRING
|
|
19
|
+
partitions => error_code partition_index leader_id [replica_nodes] [isr_nodes]
|
|
20
|
+
error_code => INT16
|
|
21
|
+
partition_index => INT32
|
|
22
|
+
leader_id => INT32
|
|
23
|
+
replica_nodes => INT32
|
|
24
|
+
isr_nodes => INT32
|
|
25
|
+
*/
|
|
26
|
+
const METADATA_V0 = (0, api_1.createApi)({
|
|
27
|
+
apiKey: 3,
|
|
28
|
+
apiVersion: 0,
|
|
29
|
+
requestHeaderVersion: 1,
|
|
30
|
+
responseHeaderVersion: 0,
|
|
31
|
+
request: (encoder, data) => encoder.writeArray(data.topics ?? [], (encoder, topic) => encoder.writeString(topic.name)),
|
|
32
|
+
response: (decoder) => {
|
|
33
|
+
const result = {
|
|
34
|
+
throttleTimeMs: 0,
|
|
35
|
+
brokers: decoder.readArray((decoder) => ({
|
|
36
|
+
nodeId: decoder.readInt32(),
|
|
37
|
+
host: decoder.readString(),
|
|
38
|
+
port: decoder.readInt32(),
|
|
39
|
+
rack: null,
|
|
40
|
+
})),
|
|
41
|
+
clusterId: null,
|
|
42
|
+
controllerId: -1,
|
|
43
|
+
topics: decoder.readArray((decoder) => ({
|
|
44
|
+
errorCode: decoder.readInt16(),
|
|
45
|
+
name: decoder.readString(),
|
|
46
|
+
topicId: '',
|
|
47
|
+
isInternal: false,
|
|
48
|
+
partitions: decoder.readArray((decoder) => ({
|
|
49
|
+
errorCode: decoder.readInt16(),
|
|
50
|
+
partitionIndex: decoder.readInt32(),
|
|
51
|
+
leaderId: decoder.readInt32(),
|
|
52
|
+
leaderEpoch: -1,
|
|
53
|
+
replicaNodes: decoder.readArray(() => decoder.readInt32()),
|
|
54
|
+
isrNodes: decoder.readArray(() => decoder.readInt32()),
|
|
55
|
+
offlineReplicas: [],
|
|
56
|
+
tags: {},
|
|
57
|
+
})),
|
|
58
|
+
topicAuthorizedOperations: -1,
|
|
59
|
+
tags: {},
|
|
60
|
+
})),
|
|
61
|
+
tags: {},
|
|
62
|
+
};
|
|
63
|
+
result.topics.forEach((topic) => {
|
|
64
|
+
if (topic.errorCode)
|
|
65
|
+
throw new error_1.KafkaTSApiError(topic.errorCode, null, result);
|
|
66
|
+
topic.partitions.forEach((partition) => {
|
|
67
|
+
if (partition.errorCode)
|
|
68
|
+
throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return result;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
/*
|
|
75
|
+
Metadata Request (Version: 12) => [topics] allow_auto_topic_creation include_topic_authorized_operations _tagged_fields
|
|
76
|
+
topics => topic_id name _tagged_fields
|
|
77
|
+
topic_id => UUID
|
|
78
|
+
name => COMPACT_NULLABLE_STRING
|
|
79
|
+
allow_auto_topic_creation => BOOLEAN
|
|
80
|
+
include_topic_authorized_operations => BOOLEAN
|
|
81
|
+
|
|
82
|
+
Metadata Response (Version: 12) => throttle_time_ms [brokers] cluster_id controller_id [topics] _tagged_fields
|
|
83
|
+
throttle_time_ms => INT32
|
|
84
|
+
brokers => node_id host port rack _tagged_fields
|
|
85
|
+
node_id => INT32
|
|
86
|
+
host => COMPACT_STRING
|
|
87
|
+
port => INT32
|
|
88
|
+
rack => COMPACT_NULLABLE_STRING
|
|
89
|
+
cluster_id => COMPACT_NULLABLE_STRING
|
|
90
|
+
controller_id => INT32
|
|
91
|
+
topics => error_code name topic_id is_internal [partitions] topic_authorized_operations _tagged_fields
|
|
92
|
+
error_code => INT16
|
|
93
|
+
name => COMPACT_NULLABLE_STRING
|
|
94
|
+
topic_id => UUID
|
|
95
|
+
is_internal => BOOLEAN
|
|
96
|
+
partitions => error_code partition_index leader_id leader_epoch [replica_nodes] [isr_nodes] [offline_replicas] _tagged_fields
|
|
97
|
+
error_code => INT16
|
|
98
|
+
partition_index => INT32
|
|
99
|
+
leader_id => INT32
|
|
100
|
+
leader_epoch => INT32
|
|
101
|
+
replica_nodes => INT32
|
|
102
|
+
isr_nodes => INT32
|
|
103
|
+
offline_replicas => INT32
|
|
104
|
+
topic_authorized_operations => INT32
|
|
105
|
+
*/
|
|
6
106
|
exports.METADATA = (0, api_1.createApi)({
|
|
7
107
|
apiKey: 3,
|
|
8
108
|
apiVersion: 12,
|
|
109
|
+
fallback: METADATA_V0,
|
|
110
|
+
requestHeaderVersion: 2,
|
|
111
|
+
responseHeaderVersion: 1,
|
|
9
112
|
request: (encoder, data) => encoder
|
|
10
|
-
.
|
|
11
|
-
.writeCompactArray(data.topics ?? null, (encoder, topic) => encoder.writeUUID(topic.id).writeCompactString(topic.name).writeUVarInt(0))
|
|
113
|
+
.writeCompactArray(data.topics ?? null, (encoder, topic) => encoder.writeUUID(topic.id).writeCompactString(topic.name).writeTagBuffer())
|
|
12
114
|
.writeBoolean(data.allowTopicAutoCreation ?? false)
|
|
13
115
|
.writeBoolean(data.includeTopicAuthorizedOperations ?? false)
|
|
14
|
-
.
|
|
116
|
+
.writeTagBuffer(),
|
|
15
117
|
response: (decoder) => {
|
|
16
118
|
const result = {
|
|
17
|
-
_tag: decoder.readTagBuffer(),
|
|
18
119
|
throttleTimeMs: decoder.readInt32(),
|
|
19
120
|
brokers: decoder.readCompactArray((broker) => ({
|
|
20
121
|
nodeId: broker.readInt32(),
|
|
21
122
|
host: broker.readCompactString(),
|
|
22
123
|
port: broker.readInt32(),
|
|
23
124
|
rack: broker.readCompactString(),
|
|
24
|
-
|
|
125
|
+
tags: broker.readTagBuffer(),
|
|
25
126
|
})),
|
|
26
127
|
clusterId: decoder.readCompactString(),
|
|
27
128
|
controllerId: decoder.readInt32(),
|
|
@@ -38,12 +139,12 @@ exports.METADATA = (0, api_1.createApi)({
|
|
|
38
139
|
replicaNodes: partition.readCompactArray((node) => node.readInt32()),
|
|
39
140
|
isrNodes: partition.readCompactArray((node) => node.readInt32()),
|
|
40
141
|
offlineReplicas: partition.readCompactArray((node) => node.readInt32()),
|
|
41
|
-
|
|
142
|
+
tags: partition.readTagBuffer(),
|
|
42
143
|
})),
|
|
43
144
|
topicAuthorizedOperations: topic.readInt32(),
|
|
44
|
-
|
|
145
|
+
tags: topic.readTagBuffer(),
|
|
45
146
|
})),
|
|
46
|
-
|
|
147
|
+
tags: decoder.readTagBuffer(),
|
|
47
148
|
};
|
|
48
149
|
result.topics.forEach((topic) => {
|
|
49
150
|
if (topic.errorCode)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type OffsetCommitRequest = {
|
|
2
2
|
groupId: string;
|
|
3
3
|
generationIdOrMemberEpoch: number;
|
|
4
4
|
memberId: string;
|
|
@@ -12,17 +12,19 @@ export declare const OFFSET_COMMIT: import("../utils/api").Api<{
|
|
|
12
12
|
committedMetadata: string | null;
|
|
13
13
|
}[];
|
|
14
14
|
}[];
|
|
15
|
-
}
|
|
16
|
-
|
|
15
|
+
};
|
|
16
|
+
type OffsetCommitResponse = {
|
|
17
17
|
throttleTimeMs: number;
|
|
18
18
|
topics: {
|
|
19
|
-
name: string
|
|
19
|
+
name: string;
|
|
20
20
|
partitions: {
|
|
21
21
|
partitionIndex: number;
|
|
22
22
|
errorCode: number;
|
|
23
|
-
|
|
23
|
+
tags: Record<number, Buffer>;
|
|
24
24
|
}[];
|
|
25
|
-
|
|
25
|
+
tags: Record<number, Buffer>;
|
|
26
26
|
}[];
|
|
27
|
-
|
|
28
|
-
}
|
|
27
|
+
tags: Record<number, Buffer>;
|
|
28
|
+
};
|
|
29
|
+
export declare const OFFSET_COMMIT: import("../utils/api").Api<OffsetCommitRequest, OffsetCommitResponse>;
|
|
30
|
+
export {};
|
|
@@ -3,11 +3,92 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OFFSET_COMMIT = void 0;
|
|
4
4
|
const api_1 = require("../utils/api");
|
|
5
5
|
const error_1 = require("../utils/error");
|
|
6
|
+
/*
|
|
7
|
+
OffsetCommit Request (Version: 2) => group_id generation_id_or_member_epoch member_id retention_time_ms [topics]
|
|
8
|
+
group_id => STRING
|
|
9
|
+
generation_id_or_member_epoch => INT32
|
|
10
|
+
member_id => STRING
|
|
11
|
+
retention_time_ms => INT64
|
|
12
|
+
topics => name [partitions]
|
|
13
|
+
name => STRING
|
|
14
|
+
partitions => partition_index committed_offset committed_metadata
|
|
15
|
+
partition_index => INT32
|
|
16
|
+
committed_offset => INT64
|
|
17
|
+
committed_metadata => NULLABLE_STRING
|
|
18
|
+
|
|
19
|
+
OffsetCommit Response (Version: 2) => [topics]
|
|
20
|
+
topics => name [partitions]
|
|
21
|
+
name => STRING
|
|
22
|
+
partitions => partition_index error_code
|
|
23
|
+
partition_index => INT32
|
|
24
|
+
error_code => INT16
|
|
25
|
+
*/
|
|
26
|
+
const OFFSET_COMMIT_V2 = (0, api_1.createApi)({
|
|
27
|
+
apiKey: 8,
|
|
28
|
+
apiVersion: 2,
|
|
29
|
+
requestHeaderVersion: 1,
|
|
30
|
+
responseHeaderVersion: 0,
|
|
31
|
+
request: (encoder, data) => encoder
|
|
32
|
+
.writeString(data.groupId)
|
|
33
|
+
.writeInt32(data.generationIdOrMemberEpoch)
|
|
34
|
+
.writeString(data.memberId)
|
|
35
|
+
.writeInt64(-1n) // retention_time_ms is deprecated and should be set to -1
|
|
36
|
+
.writeArray(data.topics, (encoder, topic) => encoder.writeString(topic.name).writeArray(topic.partitions, (encoder, partition) => encoder
|
|
37
|
+
.writeInt32(partition.partitionIndex)
|
|
38
|
+
.writeInt64(partition.committedOffset)
|
|
39
|
+
.writeString(partition.committedMetadata))),
|
|
40
|
+
response: (decoder) => {
|
|
41
|
+
const result = {
|
|
42
|
+
throttleTimeMs: 0,
|
|
43
|
+
topics: decoder.readArray((decoder) => ({
|
|
44
|
+
name: decoder.readString(),
|
|
45
|
+
partitions: decoder.readArray((decoder) => ({
|
|
46
|
+
partitionIndex: decoder.readInt32(),
|
|
47
|
+
errorCode: decoder.readInt16(),
|
|
48
|
+
tags: {},
|
|
49
|
+
})),
|
|
50
|
+
tags: {},
|
|
51
|
+
})),
|
|
52
|
+
tags: {},
|
|
53
|
+
};
|
|
54
|
+
result.topics.forEach((topic) => {
|
|
55
|
+
topic.partitions.forEach((partition) => {
|
|
56
|
+
if (partition.errorCode)
|
|
57
|
+
throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return result;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
/*
|
|
64
|
+
OffsetCommit Request (Version: 8) => group_id generation_id_or_member_epoch member_id group_instance_id [topics] _tagged_fields
|
|
65
|
+
group_id => COMPACT_STRING
|
|
66
|
+
generation_id_or_member_epoch => INT32
|
|
67
|
+
member_id => COMPACT_STRING
|
|
68
|
+
group_instance_id => COMPACT_NULLABLE_STRING
|
|
69
|
+
topics => name [partitions] _tagged_fields
|
|
70
|
+
name => COMPACT_STRING
|
|
71
|
+
partitions => partition_index committed_offset committed_leader_epoch committed_metadata _tagged_fields
|
|
72
|
+
partition_index => INT32
|
|
73
|
+
committed_offset => INT64
|
|
74
|
+
committed_leader_epoch => INT32
|
|
75
|
+
committed_metadata => COMPACT_NULLABLE_STRING
|
|
76
|
+
|
|
77
|
+
OffsetCommit Response (Version: 8) => throttle_time_ms [topics] _tagged_fields
|
|
78
|
+
throttle_time_ms => INT32
|
|
79
|
+
topics => name [partitions] _tagged_fields
|
|
80
|
+
name => COMPACT_STRING
|
|
81
|
+
partitions => partition_index error_code _tagged_fields
|
|
82
|
+
partition_index => INT32
|
|
83
|
+
error_code => INT16
|
|
84
|
+
*/
|
|
6
85
|
exports.OFFSET_COMMIT = (0, api_1.createApi)({
|
|
7
86
|
apiKey: 8,
|
|
8
87
|
apiVersion: 8,
|
|
88
|
+
fallback: OFFSET_COMMIT_V2,
|
|
89
|
+
requestHeaderVersion: 2,
|
|
90
|
+
responseHeaderVersion: 1,
|
|
9
91
|
request: (encoder, data) => encoder
|
|
10
|
-
.writeUVarInt(0)
|
|
11
92
|
.writeCompactString(data.groupId)
|
|
12
93
|
.writeInt32(data.generationIdOrMemberEpoch)
|
|
13
94
|
.writeCompactString(data.memberId)
|
|
@@ -19,23 +100,22 @@ exports.OFFSET_COMMIT = (0, api_1.createApi)({
|
|
|
19
100
|
.writeInt64(partition.committedOffset)
|
|
20
101
|
.writeInt32(partition.committedLeaderEpoch)
|
|
21
102
|
.writeCompactString(partition.committedMetadata)
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
.
|
|
103
|
+
.writeTagBuffer())
|
|
104
|
+
.writeTagBuffer())
|
|
105
|
+
.writeTagBuffer(),
|
|
25
106
|
response: (decoder) => {
|
|
26
107
|
const result = {
|
|
27
|
-
_tag: decoder.readTagBuffer(),
|
|
28
108
|
throttleTimeMs: decoder.readInt32(),
|
|
29
109
|
topics: decoder.readCompactArray((decoder) => ({
|
|
30
110
|
name: decoder.readCompactString(),
|
|
31
111
|
partitions: decoder.readCompactArray((decoder) => ({
|
|
32
112
|
partitionIndex: decoder.readInt32(),
|
|
33
113
|
errorCode: decoder.readInt16(),
|
|
34
|
-
|
|
114
|
+
tags: decoder.readTagBuffer(),
|
|
35
115
|
})),
|
|
36
|
-
|
|
116
|
+
tags: decoder.readTagBuffer(),
|
|
37
117
|
})),
|
|
38
|
-
|
|
118
|
+
tags: decoder.readTagBuffer(),
|
|
39
119
|
};
|
|
40
120
|
result.topics.forEach((topic) => {
|
|
41
121
|
topic.partitions.forEach((partition) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type OffsetFetchRequest = {
|
|
2
2
|
groups: {
|
|
3
3
|
groupId: string;
|
|
4
4
|
topics: {
|
|
@@ -7,11 +7,11 @@ export declare const OFFSET_FETCH: import("../utils/api").Api<{
|
|
|
7
7
|
}[];
|
|
8
8
|
}[];
|
|
9
9
|
requireStable: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
10
|
+
};
|
|
11
|
+
type OffsetFetchResponse = {
|
|
12
12
|
throttleTimeMs: number;
|
|
13
13
|
groups: {
|
|
14
|
-
groupId: string
|
|
14
|
+
groupId: string;
|
|
15
15
|
topics: {
|
|
16
16
|
name: string;
|
|
17
17
|
partitions: {
|
|
@@ -20,12 +20,14 @@ export declare const OFFSET_FETCH: import("../utils/api").Api<{
|
|
|
20
20
|
committedLeaderEpoch: number;
|
|
21
21
|
committedMetadata: string | null;
|
|
22
22
|
errorCode: number;
|
|
23
|
-
|
|
23
|
+
tags: Record<number, Buffer>;
|
|
24
24
|
}[];
|
|
25
|
-
|
|
25
|
+
tags: Record<number, Buffer>;
|
|
26
26
|
}[];
|
|
27
27
|
errorCode: number;
|
|
28
|
-
|
|
28
|
+
tags: Record<number, Buffer>;
|
|
29
29
|
}[];
|
|
30
|
-
|
|
31
|
-
}
|
|
30
|
+
tags: Record<number, Buffer>;
|
|
31
|
+
};
|
|
32
|
+
export declare const OFFSET_FETCH: import("../utils/api").Api<OffsetFetchRequest, OffsetFetchResponse>;
|
|
33
|
+
export {};
|