kafka-ts 1.3.1-beta.2 → 1.3.1-beta.4
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/dist/api/offset-commit.js +3 -1
- package/dist/api/sync-group.js +26 -19
- package/dist/auth/plain.d.ts +1 -1
- package/dist/broker.d.ts +1 -1
- package/dist/broker.js +4 -14
- package/dist/connection.js +4 -2
- package/dist/producer/producer-state.d.ts +1 -1
- package/package.json +1 -1
|
@@ -33,7 +33,9 @@ const OFFSET_COMMIT_V2 = (0, api_1.createApi)({
|
|
|
33
33
|
.writeInt32(data.generationIdOrMemberEpoch)
|
|
34
34
|
.writeString(data.memberId)
|
|
35
35
|
.writeInt64(-1n) // retention_time_ms is deprecated and should be set to -1
|
|
36
|
-
.writeArray(data.topics, (encoder, topic) => encoder
|
|
36
|
+
.writeArray(data.topics, (encoder, topic) => encoder
|
|
37
|
+
.writeString(topic.name)
|
|
38
|
+
.writeArray(topic.partitions, (encoder, partition) => encoder
|
|
37
39
|
.writeInt32(partition.partitionIndex)
|
|
38
40
|
.writeInt64(partition.committedOffset)
|
|
39
41
|
.writeString(partition.committedMetadata))),
|
package/dist/api/sync-group.js
CHANGED
|
@@ -6,36 +6,43 @@ const decoder_1 = require("../utils/decoder");
|
|
|
6
6
|
const encoder_1 = require("../utils/encoder");
|
|
7
7
|
const error_1 = require("../utils/error");
|
|
8
8
|
/*
|
|
9
|
-
SyncGroup Request (Version:
|
|
10
|
-
group_id =>
|
|
9
|
+
SyncGroup Request (Version: 4) => group_id generation_id member_id group_instance_id [assignments] _tagged_fields
|
|
10
|
+
group_id => COMPACT_STRING
|
|
11
11
|
generation_id => INT32
|
|
12
|
-
member_id =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
member_id => COMPACT_STRING
|
|
13
|
+
group_instance_id => COMPACT_NULLABLE_STRING
|
|
14
|
+
assignments => member_id assignment _tagged_fields
|
|
15
|
+
member_id => COMPACT_STRING
|
|
16
|
+
assignment => COMPACT_BYTES
|
|
16
17
|
|
|
17
|
-
SyncGroup Response (Version:
|
|
18
|
+
SyncGroup Response (Version: 4) => throttle_time_ms error_code assignment _tagged_fields
|
|
19
|
+
throttle_time_ms => INT32
|
|
18
20
|
error_code => INT16
|
|
19
|
-
assignment =>
|
|
21
|
+
assignment => COMPACT_BYTES
|
|
20
22
|
*/
|
|
21
|
-
const
|
|
23
|
+
const SYNC_GROUP_V4 = (0, api_1.createApi)({
|
|
22
24
|
apiKey: 14,
|
|
23
|
-
apiVersion:
|
|
24
|
-
requestHeaderVersion:
|
|
25
|
-
responseHeaderVersion:
|
|
25
|
+
apiVersion: 4,
|
|
26
|
+
requestHeaderVersion: 2,
|
|
27
|
+
responseHeaderVersion: 1,
|
|
26
28
|
request: (encoder, data) => encoder
|
|
27
|
-
.
|
|
29
|
+
.writeCompactString(data.groupId)
|
|
28
30
|
.writeInt32(data.generationId)
|
|
29
|
-
.
|
|
30
|
-
.
|
|
31
|
+
.writeCompactString(data.memberId)
|
|
32
|
+
.writeCompactString(data.groupInstanceId)
|
|
33
|
+
.writeCompactArray(data.assignments, (encoder, assignment) => encoder
|
|
34
|
+
.writeCompactString(assignment.memberId)
|
|
35
|
+
.writeCompactBytes(encodeAssignment(assignment.assignment))
|
|
36
|
+
.writeTagBuffer())
|
|
37
|
+
.writeTagBuffer(),
|
|
31
38
|
response: (decoder) => {
|
|
32
39
|
const result = {
|
|
33
|
-
throttleTimeMs:
|
|
40
|
+
throttleTimeMs: decoder.readInt32(),
|
|
34
41
|
errorCode: decoder.readInt16(),
|
|
35
42
|
protocolType: null,
|
|
36
43
|
protocolName: null,
|
|
37
|
-
assignments: decodeAssignment(decoder.
|
|
38
|
-
tags:
|
|
44
|
+
assignments: decodeAssignment(decoder.readCompactBytes()),
|
|
45
|
+
tags: decoder.readTagBuffer(),
|
|
39
46
|
};
|
|
40
47
|
if (result.errorCode)
|
|
41
48
|
throw new error_1.KafkaTSApiError(result.errorCode, null, result);
|
|
@@ -64,7 +71,7 @@ SyncGroup Response (Version: 5) => throttle_time_ms error_code protocol_type pro
|
|
|
64
71
|
exports.SYNC_GROUP = (0, api_1.createApi)({
|
|
65
72
|
apiKey: 14,
|
|
66
73
|
apiVersion: 5,
|
|
67
|
-
fallback:
|
|
74
|
+
fallback: SYNC_GROUP_V4,
|
|
68
75
|
requestHeaderVersion: 2,
|
|
69
76
|
responseHeaderVersion: 1,
|
|
70
77
|
request: (encoder, data) => encoder
|
package/dist/auth/plain.d.ts
CHANGED
package/dist/broker.d.ts
CHANGED
package/dist/broker.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Broker = void 0;
|
|
4
4
|
const api_1 = require("./api");
|
|
5
5
|
const connection_1 = require("./connection");
|
|
6
|
-
const logger_1 = require("./utils/logger");
|
|
7
6
|
class Broker {
|
|
8
7
|
options;
|
|
9
8
|
connection;
|
|
@@ -21,7 +20,7 @@ class Broker {
|
|
|
21
20
|
async connect() {
|
|
22
21
|
if (!this.connection.isConnected()) {
|
|
23
22
|
await this.connection.connect();
|
|
24
|
-
await this.
|
|
23
|
+
await this.fetchApiVersions();
|
|
25
24
|
await this.saslHandshake();
|
|
26
25
|
await this.saslAuthenticate();
|
|
27
26
|
}
|
|
@@ -30,19 +29,10 @@ class Broker {
|
|
|
30
29
|
async disconnect() {
|
|
31
30
|
await this.connection.disconnect();
|
|
32
31
|
}
|
|
33
|
-
async
|
|
32
|
+
async fetchApiVersions() {
|
|
34
33
|
const { versions } = await this.sendRequest(api_1.API.API_VERSIONS, {});
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const api = apiByKey[apiKey];
|
|
38
|
-
if (!api) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (api.apiVersion < minVersion || api.apiVersion > maxVersion) {
|
|
42
|
-
logger_1.log.warn(`Broker does not support API ${(0, api_1.getApiName)(api)} version ${api.apiVersion} (minVersion=${minVersion}, maxVersion=${maxVersion})`);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
this.connection.setVersions(versions);
|
|
34
|
+
const versionsByApiKey = Object.fromEntries(versions.map(({ apiKey, minVersion, maxVersion }) => [apiKey, { minVersion, maxVersion }]));
|
|
35
|
+
this.connection.setVersions(versionsByApiKey);
|
|
46
36
|
}
|
|
47
37
|
async saslHandshake() {
|
|
48
38
|
if (!this.options.sasl) {
|
package/dist/connection.js
CHANGED
|
@@ -118,13 +118,15 @@ class Connection {
|
|
|
118
118
|
if (!versionInfo)
|
|
119
119
|
throw new Error(`Broker does not support API ${(0, api_1.getApiName)(api)}`);
|
|
120
120
|
if (api.apiVersion < versionInfo.minVersion || api.apiVersion > versionInfo.maxVersion) {
|
|
121
|
-
if (api.fallback)
|
|
121
|
+
if (api.fallback) {
|
|
122
122
|
return this.validateVersion(api.fallback);
|
|
123
|
+
}
|
|
123
124
|
throw new Error(`Broker does not support API ${(0, api_1.getApiName)(api)} version ${api.apiVersion} (minVersion=${versionInfo.minVersion}, maxVersion=${versionInfo.maxVersion})`);
|
|
124
125
|
}
|
|
126
|
+
logger_1.log.debug(`Using API ${(0, api_1.getApiName)(api)} version ${api.apiVersion}`);
|
|
125
127
|
return api;
|
|
126
128
|
}
|
|
127
|
-
validateVersionCached = (0, cached_1.cached)(this.validateVersion, (api) => api.apiKey.toString());
|
|
129
|
+
validateVersionCached = (0, cached_1.cached)(this.validateVersion.bind(this), (api) => api.apiKey.toString());
|
|
128
130
|
async sendRequest(apiLatest, body) {
|
|
129
131
|
const api = this.validateVersionCached(apiLatest);
|
|
130
132
|
const correlationId = this.nextCorrelationId();
|