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/fetch.js
CHANGED
|
@@ -4,11 +4,129 @@ exports.FETCH = void 0;
|
|
|
4
4
|
const api_1 = require("../utils/api");
|
|
5
5
|
const decoder_1 = require("../utils/decoder");
|
|
6
6
|
const error_1 = require("../utils/error");
|
|
7
|
+
/*
|
|
8
|
+
Fetch Request (Version: 4) => replica_id max_wait_ms min_bytes max_bytes isolation_level [topics]
|
|
9
|
+
replica_id => INT32
|
|
10
|
+
max_wait_ms => INT32
|
|
11
|
+
min_bytes => INT32
|
|
12
|
+
max_bytes => INT32
|
|
13
|
+
isolation_level => INT8
|
|
14
|
+
topics => topic [partitions]
|
|
15
|
+
topic => STRING
|
|
16
|
+
partitions => partition fetch_offset partition_max_bytes
|
|
17
|
+
partition => INT32
|
|
18
|
+
fetch_offset => INT64
|
|
19
|
+
partition_max_bytes => INT32
|
|
20
|
+
|
|
21
|
+
Fetch Response (Version: 4) => throttle_time_ms [responses]
|
|
22
|
+
throttle_time_ms => INT32
|
|
23
|
+
responses => topic [partitions]
|
|
24
|
+
topic => STRING
|
|
25
|
+
partitions => partition_index error_code high_watermark last_stable_offset [aborted_transactions] records
|
|
26
|
+
partition_index => INT32
|
|
27
|
+
error_code => INT16
|
|
28
|
+
high_watermark => INT64
|
|
29
|
+
last_stable_offset => INT64
|
|
30
|
+
aborted_transactions => producer_id first_offset
|
|
31
|
+
producer_id => INT64
|
|
32
|
+
first_offset => INT64
|
|
33
|
+
records => RECORDS
|
|
34
|
+
*/
|
|
35
|
+
const FETCH_V4 = (0, api_1.createApi)({
|
|
36
|
+
apiKey: 1,
|
|
37
|
+
apiVersion: 4,
|
|
38
|
+
requestHeaderVersion: 1,
|
|
39
|
+
responseHeaderVersion: 0,
|
|
40
|
+
request: (encoder, data) => encoder
|
|
41
|
+
.writeInt32(-1) // replica_id
|
|
42
|
+
.writeInt32(data.maxWaitMs)
|
|
43
|
+
.writeInt32(data.minBytes)
|
|
44
|
+
.writeInt32(data.maxBytes)
|
|
45
|
+
.writeInt8(data.isolationLevel)
|
|
46
|
+
.writeArray(data.topics, (encoder, topic) => encoder
|
|
47
|
+
.writeString(topic.topicName)
|
|
48
|
+
.writeArray(topic.partitions, (encoder, partition) => encoder
|
|
49
|
+
.writeInt32(partition.partition)
|
|
50
|
+
.writeInt64(partition.fetchOffset)
|
|
51
|
+
.writeInt32(partition.partitionMaxBytes))),
|
|
52
|
+
response: (decoder) => {
|
|
53
|
+
const result = {
|
|
54
|
+
throttleTimeMs: decoder.readInt32(),
|
|
55
|
+
errorCode: 0,
|
|
56
|
+
sessionId: 0,
|
|
57
|
+
responses: decoder.readArray((response) => ({
|
|
58
|
+
topicName: response.readString(),
|
|
59
|
+
partitions: response.readArray((partition) => ({
|
|
60
|
+
partitionIndex: partition.readInt32(),
|
|
61
|
+
errorCode: partition.readInt16(),
|
|
62
|
+
highWatermark: partition.readInt64(),
|
|
63
|
+
lastStableOffset: partition.readInt64(),
|
|
64
|
+
logStartOffset: BigInt(0), // Not present in v4 response
|
|
65
|
+
abortedTransactions: partition.readArray((abortedTransaction) => ({
|
|
66
|
+
producerId: abortedTransaction.readInt64(),
|
|
67
|
+
firstOffset: abortedTransaction.readInt64(),
|
|
68
|
+
})),
|
|
69
|
+
preferredReadReplica: -1, // Not present in v4 response
|
|
70
|
+
records: decodeRecordBatch(partition, partition.readInt32()),
|
|
71
|
+
})),
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
74
|
+
result.responses.forEach((response) => {
|
|
75
|
+
response.partitions.forEach((partition) => {
|
|
76
|
+
if (partition.errorCode)
|
|
77
|
+
throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return result;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
/*
|
|
84
|
+
Fetch Request (Version: 15) => max_wait_ms min_bytes max_bytes isolation_level session_id session_epoch [topics] [forgotten_topics_data] rack_id _tagged_fields
|
|
85
|
+
max_wait_ms => INT32
|
|
86
|
+
min_bytes => INT32
|
|
87
|
+
max_bytes => INT32
|
|
88
|
+
isolation_level => INT8
|
|
89
|
+
session_id => INT32
|
|
90
|
+
session_epoch => INT32
|
|
91
|
+
topics => topic_id [partitions] _tagged_fields
|
|
92
|
+
topic_id => UUID
|
|
93
|
+
partitions => partition current_leader_epoch fetch_offset last_fetched_epoch log_start_offset partition_max_bytes _tagged_fields
|
|
94
|
+
partition => INT32
|
|
95
|
+
current_leader_epoch => INT32
|
|
96
|
+
fetch_offset => INT64
|
|
97
|
+
last_fetched_epoch => INT32
|
|
98
|
+
log_start_offset => INT64
|
|
99
|
+
partition_max_bytes => INT32
|
|
100
|
+
forgotten_topics_data => topic_id [partitions] _tagged_fields
|
|
101
|
+
topic_id => UUID
|
|
102
|
+
partitions => INT32
|
|
103
|
+
rack_id => COMPACT_STRING
|
|
104
|
+
|
|
105
|
+
Fetch Response (Version: 15) => throttle_time_ms error_code session_id [responses] _tagged_fields
|
|
106
|
+
throttle_time_ms => INT32
|
|
107
|
+
error_code => INT16
|
|
108
|
+
session_id => INT32
|
|
109
|
+
responses => topic_id [partitions] _tagged_fields
|
|
110
|
+
topic_id => UUID
|
|
111
|
+
partitions => partition_index error_code high_watermark last_stable_offset log_start_offset [aborted_transactions] preferred_read_replica records _tagged_fields
|
|
112
|
+
partition_index => INT32
|
|
113
|
+
error_code => INT16
|
|
114
|
+
high_watermark => INT64
|
|
115
|
+
last_stable_offset => INT64
|
|
116
|
+
log_start_offset => INT64
|
|
117
|
+
aborted_transactions => producer_id first_offset _tagged_fields
|
|
118
|
+
producer_id => INT64
|
|
119
|
+
first_offset => INT64
|
|
120
|
+
preferred_read_replica => INT32
|
|
121
|
+
records => COMPACT_RECORDS
|
|
122
|
+
*/
|
|
7
123
|
exports.FETCH = (0, api_1.createApi)({
|
|
8
124
|
apiKey: 1,
|
|
9
125
|
apiVersion: 15,
|
|
126
|
+
requestHeaderVersion: 2,
|
|
127
|
+
responseHeaderVersion: 1,
|
|
128
|
+
fallback: FETCH_V4,
|
|
10
129
|
request: (encoder, data) => encoder
|
|
11
|
-
.writeUVarInt(0)
|
|
12
130
|
.writeInt32(data.maxWaitMs)
|
|
13
131
|
.writeInt32(data.minBytes)
|
|
14
132
|
.writeInt32(data.maxBytes)
|
|
@@ -24,17 +142,16 @@ exports.FETCH = (0, api_1.createApi)({
|
|
|
24
142
|
.writeInt32(partition.lastFetchedEpoch)
|
|
25
143
|
.writeInt64(partition.logStartOffset)
|
|
26
144
|
.writeInt32(partition.partitionMaxBytes)
|
|
27
|
-
.
|
|
28
|
-
.
|
|
145
|
+
.writeTagBuffer())
|
|
146
|
+
.writeTagBuffer())
|
|
29
147
|
.writeCompactArray(data.forgottenTopicsData, (encoder, forgottenTopic) => encoder
|
|
30
148
|
.writeUUID(forgottenTopic.topicId)
|
|
31
149
|
.writeCompactArray(forgottenTopic.partitions, (encoder, partition) => encoder.writeInt32(partition))
|
|
32
|
-
.
|
|
150
|
+
.writeTagBuffer())
|
|
33
151
|
.writeCompactString(data.rackId)
|
|
34
|
-
.
|
|
152
|
+
.writeTagBuffer(),
|
|
35
153
|
response: async (decoder) => {
|
|
36
154
|
const result = {
|
|
37
|
-
_tag: decoder.readTagBuffer(),
|
|
38
155
|
throttleTimeMs: decoder.readInt32(),
|
|
39
156
|
errorCode: decoder.readInt16(),
|
|
40
157
|
sessionId: decoder.readInt32(),
|
|
@@ -49,15 +166,15 @@ exports.FETCH = (0, api_1.createApi)({
|
|
|
49
166
|
abortedTransactions: partition.readCompactArray((abortedTransaction) => ({
|
|
50
167
|
producerId: abortedTransaction.readInt64(),
|
|
51
168
|
firstOffset: abortedTransaction.readInt64(),
|
|
52
|
-
|
|
169
|
+
tags: abortedTransaction.readTagBuffer(),
|
|
53
170
|
})),
|
|
54
171
|
preferredReadReplica: partition.readInt32(),
|
|
55
|
-
records: decodeRecordBatch(partition),
|
|
56
|
-
|
|
172
|
+
records: decodeRecordBatch(partition, partition.readUVarInt() - 1),
|
|
173
|
+
tags: partition.readTagBuffer(),
|
|
57
174
|
})),
|
|
58
|
-
|
|
175
|
+
tags: response.readTagBuffer(),
|
|
59
176
|
})),
|
|
60
|
-
|
|
177
|
+
tags: decoder.readTagBuffer(),
|
|
61
178
|
};
|
|
62
179
|
if (result.errorCode)
|
|
63
180
|
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
@@ -70,8 +187,7 @@ exports.FETCH = (0, api_1.createApi)({
|
|
|
70
187
|
return result;
|
|
71
188
|
},
|
|
72
189
|
});
|
|
73
|
-
const decodeRecordBatch = (decoder) => {
|
|
74
|
-
const size = decoder.readUVarInt() - 1;
|
|
190
|
+
const decodeRecordBatch = (decoder, size) => {
|
|
75
191
|
if (size <= 0) {
|
|
76
192
|
return [];
|
|
77
193
|
}
|
|
@@ -107,6 +223,7 @@ const decodeRecordBatch = (decoder) => {
|
|
|
107
223
|
const lastOffsetDelta = batchDecoder.readInt32();
|
|
108
224
|
const baseTimestamp = batchDecoder.readInt64();
|
|
109
225
|
const maxTimestamp = batchDecoder.readInt64();
|
|
226
|
+
const deleteHorizonMs = hasDeleteHorizonMs ? baseTimestamp : null;
|
|
110
227
|
const producerId = batchDecoder.readInt64();
|
|
111
228
|
const producerEpoch = batchDecoder.readInt16();
|
|
112
229
|
const baseSequence = batchDecoder.readInt32();
|
|
@@ -123,6 +240,7 @@ const decodeRecordBatch = (decoder) => {
|
|
|
123
240
|
isTransactional,
|
|
124
241
|
isControlBatch,
|
|
125
242
|
hasDeleteHorizonMs,
|
|
243
|
+
deleteHorizonMs,
|
|
126
244
|
lastOffsetDelta,
|
|
127
245
|
baseTimestamp,
|
|
128
246
|
maxTimestamp,
|
|
@@ -2,20 +2,22 @@ export declare const KEY_TYPE: {
|
|
|
2
2
|
GROUP: number;
|
|
3
3
|
TRANSACTION: number;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type FindCoordinatorRequest = {
|
|
6
6
|
keyType: number;
|
|
7
7
|
keys: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
8
|
+
};
|
|
9
|
+
type FindCoordinatorResponse = {
|
|
10
10
|
throttleTimeMs: number;
|
|
11
11
|
coordinators: {
|
|
12
|
-
key: string
|
|
12
|
+
key: string;
|
|
13
13
|
nodeId: number;
|
|
14
14
|
host: string;
|
|
15
15
|
port: number;
|
|
16
16
|
errorCode: number;
|
|
17
17
|
errorMessage: string | null;
|
|
18
|
-
|
|
18
|
+
tags: Record<number, Buffer>;
|
|
19
19
|
}[];
|
|
20
|
-
|
|
21
|
-
}
|
|
20
|
+
tags: Record<number, Buffer>;
|
|
21
|
+
};
|
|
22
|
+
export declare const FIND_COORDINATOR: import("../utils/api").Api<FindCoordinatorRequest, FindCoordinatorResponse>;
|
|
23
|
+
export {};
|
|
@@ -7,17 +7,75 @@ exports.KEY_TYPE = {
|
|
|
7
7
|
GROUP: 0,
|
|
8
8
|
TRANSACTION: 1,
|
|
9
9
|
};
|
|
10
|
+
/*
|
|
11
|
+
FindCoordinator Request (Version: 1) => key key_type
|
|
12
|
+
key => STRING
|
|
13
|
+
key_type => INT8
|
|
14
|
+
|
|
15
|
+
FindCoordinator Response (Version: 1) => throttle_time_ms error_code error_message node_id host port
|
|
16
|
+
throttle_time_ms => INT32
|
|
17
|
+
error_code => INT16
|
|
18
|
+
error_message => NULLABLE_STRING
|
|
19
|
+
node_id => INT32
|
|
20
|
+
host => STRING
|
|
21
|
+
port => INT32
|
|
22
|
+
*/
|
|
23
|
+
const FIND_COORDINATOR_V1 = (0, api_1.createApi)({
|
|
24
|
+
apiKey: 10,
|
|
25
|
+
apiVersion: 1,
|
|
26
|
+
requestHeaderVersion: 1,
|
|
27
|
+
responseHeaderVersion: 0,
|
|
28
|
+
request: (encoder, data) => encoder.writeString(data.keys[0]).writeInt8(data.keyType),
|
|
29
|
+
response: (decoder) => {
|
|
30
|
+
const result = {
|
|
31
|
+
throttleTimeMs: decoder.readInt32(),
|
|
32
|
+
errorCode: decoder.readInt16(),
|
|
33
|
+
errorMessage: decoder.readString(),
|
|
34
|
+
coordinators: [
|
|
35
|
+
{
|
|
36
|
+
key: '', // Key not present in v1 response
|
|
37
|
+
nodeId: decoder.readInt32(),
|
|
38
|
+
host: decoder.readString(),
|
|
39
|
+
port: decoder.readInt32(),
|
|
40
|
+
errorCode: 0,
|
|
41
|
+
errorMessage: null,
|
|
42
|
+
tags: {},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
tags: {},
|
|
46
|
+
};
|
|
47
|
+
if (result.errorCode)
|
|
48
|
+
throw new error_1.KafkaTSApiError(result.errorCode, result.errorMessage, result);
|
|
49
|
+
return result;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
/*
|
|
53
|
+
FindCoordinator Request (Version: 4) => key_type [coordinator_keys] _tagged_fields
|
|
54
|
+
key_type => INT8
|
|
55
|
+
coordinator_keys => COMPACT_STRING
|
|
56
|
+
|
|
57
|
+
FindCoordinator Response (Version: 4) => throttle_time_ms [coordinators] _tagged_fields
|
|
58
|
+
throttle_time_ms => INT32
|
|
59
|
+
coordinators => key node_id host port error_code error_message _tagged_fields
|
|
60
|
+
key => COMPACT_STRING
|
|
61
|
+
node_id => INT32
|
|
62
|
+
host => COMPACT_STRING
|
|
63
|
+
port => INT32
|
|
64
|
+
error_code => INT16
|
|
65
|
+
error_message => COMPACT_NULLABLE_STRING
|
|
66
|
+
*/
|
|
10
67
|
exports.FIND_COORDINATOR = (0, api_1.createApi)({
|
|
11
68
|
apiKey: 10,
|
|
12
69
|
apiVersion: 4,
|
|
70
|
+
fallback: FIND_COORDINATOR_V1,
|
|
71
|
+
requestHeaderVersion: 2,
|
|
72
|
+
responseHeaderVersion: 1,
|
|
13
73
|
request: (encoder, data) => encoder
|
|
14
|
-
.writeUVarInt(0)
|
|
15
74
|
.writeInt8(data.keyType)
|
|
16
75
|
.writeCompactArray(data.keys, (encoder, key) => encoder.writeCompactString(key))
|
|
17
|
-
.
|
|
76
|
+
.writeTagBuffer(),
|
|
18
77
|
response: (decoder) => {
|
|
19
78
|
const result = {
|
|
20
|
-
_tag: decoder.readTagBuffer(),
|
|
21
79
|
throttleTimeMs: decoder.readInt32(),
|
|
22
80
|
coordinators: decoder.readCompactArray((decoder) => ({
|
|
23
81
|
key: decoder.readCompactString(),
|
|
@@ -26,9 +84,9 @@ exports.FIND_COORDINATOR = (0, api_1.createApi)({
|
|
|
26
84
|
port: decoder.readInt32(),
|
|
27
85
|
errorCode: decoder.readInt16(),
|
|
28
86
|
errorMessage: decoder.readCompactString(),
|
|
29
|
-
|
|
87
|
+
tags: decoder.readTagBuffer(),
|
|
30
88
|
})),
|
|
31
|
-
|
|
89
|
+
tags: decoder.readTagBuffer(),
|
|
32
90
|
};
|
|
33
91
|
result.coordinators.forEach((coordinator) => {
|
|
34
92
|
if (coordinator.errorCode)
|
package/dist/api/heartbeat.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
type HeartbeatRequest = {
|
|
2
2
|
groupId: string;
|
|
3
3
|
generationId: number;
|
|
4
4
|
memberId: string;
|
|
5
5
|
groupInstanceId: string | null;
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
};
|
|
7
|
+
type HeartbeatResponse = {
|
|
8
8
|
throttleTimeMs: number;
|
|
9
9
|
errorCode: number;
|
|
10
|
-
|
|
11
|
-
}
|
|
10
|
+
tags: Record<number, Buffer>;
|
|
11
|
+
};
|
|
12
|
+
export declare const HEARTBEAT: import("../utils/api").Api<HeartbeatRequest, HeartbeatResponse>;
|
|
13
|
+
export {};
|
package/dist/api/heartbeat.js
CHANGED
|
@@ -3,22 +3,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HEARTBEAT = void 0;
|
|
4
4
|
const api_1 = require("../utils/api");
|
|
5
5
|
const error_1 = require("../utils/error");
|
|
6
|
+
/*
|
|
7
|
+
Heartbeat Request (Version: 0) => group_id generation_id member_id
|
|
8
|
+
group_id => STRING
|
|
9
|
+
generation_id => INT32
|
|
10
|
+
member_id => STRING
|
|
11
|
+
|
|
12
|
+
Heartbeat Response (Version: 0) => error_code
|
|
13
|
+
error_code => INT16
|
|
14
|
+
*/
|
|
15
|
+
const HEARTBEAT_V0 = (0, api_1.createApi)({
|
|
16
|
+
apiKey: 12,
|
|
17
|
+
apiVersion: 0,
|
|
18
|
+
requestHeaderVersion: 1,
|
|
19
|
+
responseHeaderVersion: 0,
|
|
20
|
+
request: (encoder, data) => encoder.writeString(data.groupId).writeInt32(data.generationId).writeString(data.memberId),
|
|
21
|
+
response: (decoder) => {
|
|
22
|
+
const result = {
|
|
23
|
+
throttleTimeMs: 0,
|
|
24
|
+
errorCode: decoder.readInt16(),
|
|
25
|
+
tags: {},
|
|
26
|
+
};
|
|
27
|
+
if (result.errorCode)
|
|
28
|
+
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
29
|
+
return result;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
/*
|
|
33
|
+
Heartbeat Request (Version: 4) => group_id generation_id member_id group_instance_id _tagged_fields
|
|
34
|
+
group_id => COMPACT_STRING
|
|
35
|
+
generation_id => INT32
|
|
36
|
+
member_id => COMPACT_STRING
|
|
37
|
+
group_instance_id => COMPACT_NULLABLE_STRING
|
|
38
|
+
|
|
39
|
+
Heartbeat Response (Version: 4) => throttle_time_ms error_code _tagged_fields
|
|
40
|
+
throttle_time_ms => INT32
|
|
41
|
+
error_code => INT16
|
|
42
|
+
*/
|
|
6
43
|
exports.HEARTBEAT = (0, api_1.createApi)({
|
|
7
44
|
apiKey: 12,
|
|
8
45
|
apiVersion: 4,
|
|
46
|
+
fallback: HEARTBEAT_V0,
|
|
47
|
+
requestHeaderVersion: 2,
|
|
48
|
+
responseHeaderVersion: 1,
|
|
9
49
|
request: (encoder, data) => encoder
|
|
10
|
-
.writeUVarInt(0)
|
|
11
50
|
.writeCompactString(data.groupId)
|
|
12
51
|
.writeInt32(data.generationId)
|
|
13
52
|
.writeCompactString(data.memberId)
|
|
14
53
|
.writeCompactString(data.groupInstanceId)
|
|
15
|
-
.
|
|
54
|
+
.writeTagBuffer(),
|
|
16
55
|
response: (decoder) => {
|
|
17
56
|
const result = {
|
|
18
|
-
_tag: decoder.readTagBuffer(),
|
|
19
57
|
throttleTimeMs: decoder.readInt32(),
|
|
20
58
|
errorCode: decoder.readInt16(),
|
|
21
|
-
|
|
59
|
+
tags: decoder.readTagBuffer(),
|
|
22
60
|
};
|
|
23
61
|
if (result.errorCode)
|
|
24
62
|
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|