kafka-ts 1.3.1-beta.3 → 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.
@@ -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: 0) => group_id generation_id member_id [assignments]
10
- group_id => STRING
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 => STRING
13
- assignments => member_id assignment
14
- member_id => STRING
15
- assignment => BYTES
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: 0) => error_code assignment
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 => BYTES
21
+ assignment => COMPACT_BYTES
20
22
  */
21
- const SYNC_GROUP_V0 = (0, api_1.createApi)({
23
+ const SYNC_GROUP_V4 = (0, api_1.createApi)({
22
24
  apiKey: 14,
23
- apiVersion: 0,
24
- requestHeaderVersion: 1,
25
- responseHeaderVersion: 0,
25
+ apiVersion: 4,
26
+ requestHeaderVersion: 2,
27
+ responseHeaderVersion: 1,
26
28
  request: (encoder, data) => encoder
27
- .writeString(data.groupId)
29
+ .writeCompactString(data.groupId)
28
30
  .writeInt32(data.generationId)
29
- .writeString(data.memberId)
30
- .writeArray(data.assignments, (encoder, assignment) => encoder.writeString(assignment.memberId).writeBytes(encodeAssignment(assignment.assignment))),
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: 0,
40
+ throttleTimeMs: decoder.readInt32(),
34
41
  errorCode: decoder.readInt16(),
35
42
  protocolType: null,
36
43
  protocolName: null,
37
- assignments: decodeAssignment(decoder.readBytes()),
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: SYNC_GROUP_V0,
74
+ fallback: SYNC_GROUP_V4,
68
75
  requestHeaderVersion: 2,
69
76
  responseHeaderVersion: 1,
70
77
  request: (encoder, data) => encoder
package/dist/broker.d.ts CHANGED
@@ -21,7 +21,7 @@ export declare class Broker {
21
21
  constructor(options: BrokerOptions);
22
22
  connect(): Promise<this>;
23
23
  disconnect(): Promise<void>;
24
- private validateApiVersions;
24
+ private fetchApiVersions;
25
25
  private saslHandshake;
26
26
  private saslAuthenticate;
27
27
  }
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.validateApiVersions();
23
+ await this.fetchApiVersions();
25
24
  await this.saslHandshake();
26
25
  await this.saslAuthenticate();
27
26
  }
@@ -30,18 +29,8 @@ class Broker {
30
29
  async disconnect() {
31
30
  await this.connection.disconnect();
32
31
  }
33
- async validateApiVersions() {
32
+ async fetchApiVersions() {
34
33
  const { versions } = await this.sendRequest(api_1.API.API_VERSIONS, {});
35
- const apiByKey = Object.fromEntries(Object.values(api_1.API).map((api) => [api.apiKey, api]));
36
- versions.forEach(({ apiKey, minVersion, maxVersion }) => {
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
34
  const versionsByApiKey = Object.fromEntries(versions.map(({ apiKey, minVersion, maxVersion }) => [apiKey, { minVersion, maxVersion }]));
46
35
  this.connection.setVersions(versionsByApiKey);
47
36
  }
@@ -123,6 +123,7 @@ class Connection {
123
123
  }
124
124
  throw new Error(`Broker does not support API ${(0, api_1.getApiName)(api)} version ${api.apiVersion} (minVersion=${versionInfo.minVersion}, maxVersion=${versionInfo.maxVersion})`);
125
125
  }
126
+ logger_1.log.debug(`Using API ${(0, api_1.getApiName)(api)} version ${api.apiVersion}`);
126
127
  return api;
127
128
  }
128
129
  validateVersionCached = (0, cached_1.cached)(this.validateVersion.bind(this), (api) => api.apiKey.toString());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-ts",
3
- "version": "1.3.1-beta.3",
3
+ "version": "1.3.1-beta.4",
4
4
  "main": "dist/index.js",
5
5
  "author": "Priit Käärd",
6
6
  "license": "MIT",