@platformatic/kafka 1.19.0 → 1.21.0
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/apis/admin/create-partitions-v1.d.ts +24 -0
- package/dist/apis/admin/create-partitions-v1.js +53 -0
- package/dist/apis/admin/create-partitions-v2.d.ts +24 -0
- package/dist/apis/admin/create-partitions-v2.js +54 -0
- package/dist/apis/admin/describe-configs-v2.d.ts +38 -0
- package/dist/apis/admin/describe-configs-v2.js +84 -0
- package/dist/apis/admin/describe-configs-v3.d.ts +38 -0
- package/dist/apis/admin/describe-configs-v3.js +84 -0
- package/dist/apis/admin/index.d.ts +4 -0
- package/dist/apis/admin/index.js +4 -0
- package/dist/apis/callbacks.js +1 -0
- package/dist/apis/consumer/fetch-v12.d.ts +46 -0
- package/dist/apis/consumer/fetch-v12.js +123 -0
- package/dist/apis/consumer/fetch-v13.d.ts +46 -0
- package/dist/apis/consumer/fetch-v13.js +123 -0
- package/dist/apis/consumer/fetch-v14.d.ts +46 -0
- package/dist/apis/consumer/fetch-v14.js +123 -0
- package/dist/apis/consumer/index.d.ts +4 -0
- package/dist/apis/consumer/index.js +4 -0
- package/dist/apis/consumer/offset-for-leader-epoch-v4.d.ts +29 -0
- package/dist/apis/consumer/offset-for-leader-epoch-v4.js +65 -0
- package/dist/apis/metadata/index.d.ts +3 -0
- package/dist/apis/metadata/index.js +3 -0
- package/dist/apis/metadata/metadata-v10.d.ts +37 -0
- package/dist/apis/metadata/metadata-v10.js +96 -0
- package/dist/apis/metadata/metadata-v11.d.ts +37 -0
- package/dist/apis/metadata/metadata-v11.js +96 -0
- package/dist/apis/metadata/metadata-v9.d.ts +37 -0
- package/dist/apis/metadata/metadata-v9.js +96 -0
- package/dist/apis/producer/index.d.ts +2 -0
- package/dist/apis/producer/index.js +2 -0
- package/dist/apis/producer/produce-v7.d.ts +29 -0
- package/dist/apis/producer/produce-v7.js +88 -0
- package/dist/apis/producer/produce-v8.d.ts +29 -0
- package/dist/apis/producer/produce-v8.js +101 -0
- package/dist/clients/admin/admin.js +16 -12
- package/dist/clients/admin/types.d.ts +4 -4
- package/dist/clients/base/base.d.ts +1 -2
- package/dist/clients/base/base.js +100 -98
- package/dist/clients/base/index.d.ts +1 -1
- package/dist/clients/base/index.js +1 -1
- package/dist/clients/consumer/consumer.js +5 -3
- package/dist/clients/consumer/messages-stream.d.ts +8 -0
- package/dist/clients/consumer/messages-stream.js +30 -1
- package/dist/clients/producer/producer.js +2 -2
- package/dist/network/connection.js +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
Metadata Request (Version: 11) => [topics] allow_auto_topic_creation include_topic_authorized_operations TAG_BUFFER
|
|
6
|
+
topics => topic_id name TAG_BUFFER
|
|
7
|
+
topic_id => UUID
|
|
8
|
+
name => COMPACT_NULLABLE_STRING
|
|
9
|
+
allow_auto_topic_creation => BOOLEAN
|
|
10
|
+
include_cluster_authorized_operations => BOOLEAN
|
|
11
|
+
include_topic_authorized_operations => BOOLEAN
|
|
12
|
+
*/
|
|
13
|
+
export function createRequest(topics, allowAutoTopicCreation = false, includeTopicAuthorizedOperations = false) {
|
|
14
|
+
return Writer.create()
|
|
15
|
+
.appendArray(topics, (w, topic) => w.appendUUID(null).appendString(topic))
|
|
16
|
+
.appendBoolean(allowAutoTopicCreation)
|
|
17
|
+
.appendBoolean(false) // include_cluster_authorized_operations (not supported from newer versions)
|
|
18
|
+
.appendBoolean(includeTopicAuthorizedOperations)
|
|
19
|
+
.appendTaggedFields();
|
|
20
|
+
}
|
|
21
|
+
/*
|
|
22
|
+
Metadata Response (Version: 11) => throttle_time_ms [brokers] cluster_id controller_id [topics] TAG_BUFFER
|
|
23
|
+
throttle_time_ms => INT32
|
|
24
|
+
brokers => node_id host port rack TAG_BUFFER
|
|
25
|
+
node_id => INT32
|
|
26
|
+
host => COMPACT_STRING
|
|
27
|
+
port => INT32
|
|
28
|
+
rack => COMPACT_NULLABLE_STRING
|
|
29
|
+
cluster_id => COMPACT_NULLABLE_STRING
|
|
30
|
+
controller_id => INT32
|
|
31
|
+
topics => error_code name topic_id is_internal [partitions] topic_authorized_operations TAG_BUFFER
|
|
32
|
+
error_code => INT16
|
|
33
|
+
name => COMPACT_NULLABLE_STRING
|
|
34
|
+
topic_id => UUID
|
|
35
|
+
is_internal => BOOLEAN
|
|
36
|
+
partitions => error_code partition_index leader_id leader_epoch [replica_nodes] [isr_nodes] [offline_replicas] TAG_BUFFER
|
|
37
|
+
error_code => INT16
|
|
38
|
+
partition_index => INT32
|
|
39
|
+
leader_id => INT32
|
|
40
|
+
leader_epoch => INT32
|
|
41
|
+
replica_nodes => INT32
|
|
42
|
+
isr_nodes => INT32
|
|
43
|
+
offline_replicas => INT32
|
|
44
|
+
topic_authorized_operations => INT32
|
|
45
|
+
cluster_authorized_operations => BOOLEAN
|
|
46
|
+
*/
|
|
47
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
const response = {
|
|
50
|
+
throttleTimeMs: reader.readInt32(),
|
|
51
|
+
brokers: reader.readArray(r => {
|
|
52
|
+
return {
|
|
53
|
+
nodeId: r.readInt32(),
|
|
54
|
+
host: r.readString(),
|
|
55
|
+
port: r.readInt32(),
|
|
56
|
+
rack: r.readNullableString()
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
clusterId: reader.readNullableString(),
|
|
60
|
+
controllerId: reader.readInt32(),
|
|
61
|
+
topics: reader.readArray((r, i) => {
|
|
62
|
+
const errorCode = r.readInt16();
|
|
63
|
+
if (errorCode !== 0) {
|
|
64
|
+
errors.push([`/topics/${i}`, errorCode]);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
errorCode,
|
|
68
|
+
name: r.readNullableString(),
|
|
69
|
+
topicId: r.readUUID(),
|
|
70
|
+
isInternal: r.readBoolean(),
|
|
71
|
+
partitions: r.readArray((r, j) => {
|
|
72
|
+
const errorCode = r.readInt16();
|
|
73
|
+
if (errorCode !== 0) {
|
|
74
|
+
errors.push([`/topics/${i}/partitions/${j}`, errorCode]);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
errorCode,
|
|
78
|
+
partitionIndex: r.readInt32(),
|
|
79
|
+
leaderId: r.readInt32(),
|
|
80
|
+
leaderEpoch: r.readInt32(),
|
|
81
|
+
replicaNodes: r.readArray(() => r.readInt32(), true, false),
|
|
82
|
+
isrNodes: r.readArray(() => r.readInt32(), true, false),
|
|
83
|
+
offlineReplicas: r.readArray(() => r.readInt32(), true, false)
|
|
84
|
+
};
|
|
85
|
+
}),
|
|
86
|
+
topicAuthorizedOperations: reader.readInt32()
|
|
87
|
+
};
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
reader.readBoolean(); // Skip cluster_authorized_operations
|
|
91
|
+
if (errors.length) {
|
|
92
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
93
|
+
}
|
|
94
|
+
return response;
|
|
95
|
+
}
|
|
96
|
+
export const api = createAPI(3, 11, createRequest, parseResponse);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
4
|
+
export type MetadataRequest = Parameters<typeof createRequest>;
|
|
5
|
+
export interface MetadataResponsePartition {
|
|
6
|
+
errorCode: number;
|
|
7
|
+
partitionIndex: number;
|
|
8
|
+
leaderId: number;
|
|
9
|
+
leaderEpoch: number;
|
|
10
|
+
replicaNodes: number[];
|
|
11
|
+
isrNodes: number[];
|
|
12
|
+
offlineReplicas: number[];
|
|
13
|
+
}
|
|
14
|
+
export interface MetadataResponseTopic {
|
|
15
|
+
errorCode: number;
|
|
16
|
+
name: NullableString;
|
|
17
|
+
topicId: string;
|
|
18
|
+
isInternal: boolean;
|
|
19
|
+
partitions: MetadataResponsePartition[];
|
|
20
|
+
topicAuthorizedOperations: number;
|
|
21
|
+
}
|
|
22
|
+
export interface MetadataResponseBroker {
|
|
23
|
+
nodeId: number;
|
|
24
|
+
host: string;
|
|
25
|
+
port: number;
|
|
26
|
+
rack: NullableString;
|
|
27
|
+
}
|
|
28
|
+
export interface MetadataResponse {
|
|
29
|
+
throttleTimeMs: number;
|
|
30
|
+
brokers: MetadataResponseBroker[];
|
|
31
|
+
clusterId: NullableString;
|
|
32
|
+
controllerId: number;
|
|
33
|
+
topics: MetadataResponseTopic[];
|
|
34
|
+
}
|
|
35
|
+
export declare function createRequest(topics: string[] | null, allowAutoTopicCreation?: boolean, includeTopicAuthorizedOperations?: boolean): Writer;
|
|
36
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): MetadataResponse;
|
|
37
|
+
export declare const api: import("../definitions.ts").API<[topics: string[] | null, allowAutoTopicCreation?: boolean | undefined, includeTopicAuthorizedOperations?: boolean | undefined], MetadataResponse>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
Metadata Request (Version: 9) => [topics] allow_auto_topic_creation include_topic_authorized_operations TAG_BUFFER
|
|
6
|
+
topics => topic_id name TAG_BUFFER
|
|
7
|
+
name => COMPACT_NULLABLE_STRING
|
|
8
|
+
allow_auto_topic_creation => BOOLEAN
|
|
9
|
+
include_cluster_authorized_operations => BOOLEAN
|
|
10
|
+
include_topic_authorized_operations => BOOLEAN
|
|
11
|
+
*/
|
|
12
|
+
export function createRequest(topics, allowAutoTopicCreation = false, includeTopicAuthorizedOperations = false) {
|
|
13
|
+
return Writer.create()
|
|
14
|
+
.appendArray(topics, (w, topic) => w.appendString(topic))
|
|
15
|
+
.appendBoolean(allowAutoTopicCreation)
|
|
16
|
+
.appendBoolean(false) // include_cluster_authorized_operations (not supported from newer versions)
|
|
17
|
+
.appendBoolean(includeTopicAuthorizedOperations)
|
|
18
|
+
.appendTaggedFields();
|
|
19
|
+
}
|
|
20
|
+
/*
|
|
21
|
+
Metadata Response (Version: 9) => throttle_time_ms [brokers] cluster_id controller_id [topics] TAG_BUFFER
|
|
22
|
+
throttle_time_ms => INT32
|
|
23
|
+
brokers => node_id host port rack TAG_BUFFER
|
|
24
|
+
node_id => INT32
|
|
25
|
+
host => COMPACT_STRING
|
|
26
|
+
port => INT32
|
|
27
|
+
rack => COMPACT_NULLABLE_STRING
|
|
28
|
+
cluster_id => COMPACT_NULLABLE_STRING
|
|
29
|
+
controller_id => INT32
|
|
30
|
+
topics => error_code name topic_id is_internal [partitions] topic_authorized_operations TAG_BUFFER
|
|
31
|
+
error_code => INT16
|
|
32
|
+
name => COMPACT_NULLABLE_STRING
|
|
33
|
+
topic_id => UUID
|
|
34
|
+
is_internal => BOOLEAN
|
|
35
|
+
partitions => error_code partition_index leader_id leader_epoch [replica_nodes] [isr_nodes] [offline_replicas] TAG_BUFFER
|
|
36
|
+
error_code => INT16
|
|
37
|
+
partition_index => INT32
|
|
38
|
+
leader_id => INT32
|
|
39
|
+
leader_epoch => INT32
|
|
40
|
+
replica_nodes => INT32
|
|
41
|
+
isr_nodes => INT32
|
|
42
|
+
offline_replicas => INT32
|
|
43
|
+
topic_authorized_operations => INT32
|
|
44
|
+
cluster_authorized_operations => BOOLEAN
|
|
45
|
+
*/
|
|
46
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
47
|
+
const errors = [];
|
|
48
|
+
const response = {
|
|
49
|
+
throttleTimeMs: reader.readInt32(),
|
|
50
|
+
brokers: reader.readArray(r => {
|
|
51
|
+
return {
|
|
52
|
+
nodeId: r.readInt32(),
|
|
53
|
+
host: r.readString(),
|
|
54
|
+
port: r.readInt32(),
|
|
55
|
+
rack: r.readNullableString()
|
|
56
|
+
};
|
|
57
|
+
}),
|
|
58
|
+
clusterId: reader.readNullableString(),
|
|
59
|
+
controllerId: reader.readInt32(),
|
|
60
|
+
topics: reader.readArray((r, i) => {
|
|
61
|
+
const errorCode = r.readInt16();
|
|
62
|
+
if (errorCode !== 0) {
|
|
63
|
+
errors.push([`/topics/${i}`, errorCode]);
|
|
64
|
+
}
|
|
65
|
+
const name = r.readNullableString();
|
|
66
|
+
return {
|
|
67
|
+
errorCode,
|
|
68
|
+
name,
|
|
69
|
+
topicId: name,
|
|
70
|
+
isInternal: r.readBoolean(),
|
|
71
|
+
partitions: r.readArray((r, j) => {
|
|
72
|
+
const errorCode = r.readInt16();
|
|
73
|
+
if (errorCode !== 0) {
|
|
74
|
+
errors.push([`/topics/${i}/partitions/${j}`, errorCode]);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
errorCode,
|
|
78
|
+
partitionIndex: r.readInt32(),
|
|
79
|
+
leaderId: r.readInt32(),
|
|
80
|
+
leaderEpoch: r.readInt32(),
|
|
81
|
+
replicaNodes: r.readArray(() => r.readInt32(), true, false),
|
|
82
|
+
isrNodes: r.readArray(() => r.readInt32(), true, false),
|
|
83
|
+
offlineReplicas: r.readArray(() => r.readInt32(), true, false)
|
|
84
|
+
};
|
|
85
|
+
}),
|
|
86
|
+
topicAuthorizedOperations: reader.readInt32()
|
|
87
|
+
};
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
reader.readBoolean(); // Skip cluster_authorized_operations
|
|
91
|
+
if (errors.length) {
|
|
92
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
93
|
+
}
|
|
94
|
+
return response;
|
|
95
|
+
}
|
|
96
|
+
export const api = createAPI(3, 9, createRequest, parseResponse);
|
|
@@ -5,5 +5,7 @@ export * as initProducerIdV4 from './init-producer-id-v4.ts';
|
|
|
5
5
|
export * as initProducerIdV5 from './init-producer-id-v5.ts';
|
|
6
6
|
export * as produceV10 from './produce-v10.ts';
|
|
7
7
|
export * as produceV11 from './produce-v11.ts';
|
|
8
|
+
export * as produceV7 from './produce-v7.ts';
|
|
9
|
+
export * as produceV8 from './produce-v8.ts';
|
|
8
10
|
export * as produceV9 from './produce-v9.ts';
|
|
9
11
|
export * as txnOffsetCommitV4 from './txn-offset-commit-v4.ts';
|
|
@@ -5,5 +5,7 @@ export * as initProducerIdV4 from "./init-producer-id-v4.js";
|
|
|
5
5
|
export * as initProducerIdV5 from "./init-producer-id-v5.js";
|
|
6
6
|
export * as produceV10 from "./produce-v10.js";
|
|
7
7
|
export * as produceV11 from "./produce-v11.js";
|
|
8
|
+
export * as produceV7 from "./produce-v7.js";
|
|
9
|
+
export * as produceV8 from "./produce-v8.js";
|
|
8
10
|
export * as produceV9 from "./produce-v9.js";
|
|
9
11
|
export * as txnOffsetCommitV4 from "./txn-offset-commit-v4.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { type CreateRecordsBatchOptions, type MessageRecord } from '../../protocol/records.ts';
|
|
4
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
5
|
+
export type ProduceRequest = Parameters<typeof createRequest>;
|
|
6
|
+
export interface ProduceResponsePartitionRecordError {
|
|
7
|
+
batchIndex: number;
|
|
8
|
+
batchIndexErrorMessage: NullableString;
|
|
9
|
+
}
|
|
10
|
+
export interface ProduceResponsePartition {
|
|
11
|
+
index: number;
|
|
12
|
+
errorCode: number;
|
|
13
|
+
baseOffset: bigint;
|
|
14
|
+
logAppendTimeMs: bigint;
|
|
15
|
+
logStartOffset: bigint;
|
|
16
|
+
recordErrors: ProduceResponsePartitionRecordError[];
|
|
17
|
+
errorMessage: NullableString;
|
|
18
|
+
}
|
|
19
|
+
export interface ProduceResponseTopic {
|
|
20
|
+
name: string;
|
|
21
|
+
partitionResponses: ProduceResponsePartition[];
|
|
22
|
+
}
|
|
23
|
+
export interface ProduceResponse {
|
|
24
|
+
responses: ProduceResponseTopic[];
|
|
25
|
+
throttleTimeMs: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function createRequest(acks: number | undefined, timeout: number | undefined, topicData: MessageRecord[], options?: Partial<CreateRecordsBatchOptions>): Writer;
|
|
28
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ProduceResponse;
|
|
29
|
+
export declare const api: import("../definitions.ts").API<[acks: number | undefined, timeout: number | undefined, topicData: MessageRecord[], options?: Partial<CreateRecordsBatchOptions> | undefined], boolean | ProduceResponse>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { createRecordsBatch } from "../../protocol/records.js";
|
|
3
|
+
import { Writer } from "../../protocol/writer.js";
|
|
4
|
+
import { groupByProperty } from "../../utils.js";
|
|
5
|
+
import { createAPI } from "../definitions.js";
|
|
6
|
+
import { ProduceAcks } from "../enumerations.js";
|
|
7
|
+
/*
|
|
8
|
+
Produce Request (Version: 7) => transactional_id acks timeout_ms [topic_data]
|
|
9
|
+
transactional_id => NULLABLE_STRING
|
|
10
|
+
acks => INT16
|
|
11
|
+
timeout_ms => INT32
|
|
12
|
+
topic_data => name [partition_data]
|
|
13
|
+
name => STRING
|
|
14
|
+
partition_data => index records
|
|
15
|
+
index => INT32
|
|
16
|
+
records => RECORDS
|
|
17
|
+
*/
|
|
18
|
+
export function createRequest(acks = 1, timeout = 0, topicData, options = {}) {
|
|
19
|
+
// Normalize the messages
|
|
20
|
+
const now = BigInt(Date.now());
|
|
21
|
+
for (const message of topicData) {
|
|
22
|
+
if (typeof message.partition === 'undefined') {
|
|
23
|
+
message.partition = 0;
|
|
24
|
+
}
|
|
25
|
+
if (typeof message.timestamp === 'undefined') {
|
|
26
|
+
message.timestamp = now;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const writer = Writer.create()
|
|
30
|
+
.appendString(options.transactionalId, false)
|
|
31
|
+
.appendInt16(acks)
|
|
32
|
+
.appendInt32(timeout)
|
|
33
|
+
.appendArray(groupByProperty(topicData, 'topic'), (w, [topic, messages]) => {
|
|
34
|
+
w.appendString(topic, false).appendArray(groupByProperty(messages, 'partition'), (w, [partition, messages]) => {
|
|
35
|
+
const records = createRecordsBatch(messages, options);
|
|
36
|
+
w.appendInt32(partition).appendInt32(records.length).appendFrom(records);
|
|
37
|
+
}, false, false);
|
|
38
|
+
}, false, false);
|
|
39
|
+
if (acks === ProduceAcks.NO_RESPONSE) {
|
|
40
|
+
writer.context.noResponse = true;
|
|
41
|
+
}
|
|
42
|
+
return writer;
|
|
43
|
+
}
|
|
44
|
+
/*
|
|
45
|
+
Produce Response (Version: 7) => [responses] throttle_time_ms
|
|
46
|
+
responses => name [partition_responses]
|
|
47
|
+
name => STRING
|
|
48
|
+
partition_responses => index error_code base_offset log_append_time_ms log_start_offset [record_errors] error_message
|
|
49
|
+
index => INT32
|
|
50
|
+
error_code => INT16
|
|
51
|
+
base_offset => INT64
|
|
52
|
+
log_append_time_ms => INT64
|
|
53
|
+
log_start_offset => INT64
|
|
54
|
+
throttle_time_ms => INT32
|
|
55
|
+
*/
|
|
56
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
57
|
+
const errors = [];
|
|
58
|
+
const response = {
|
|
59
|
+
responses: reader.readArray((r, i) => {
|
|
60
|
+
const topicResponse = {
|
|
61
|
+
name: r.readString(false),
|
|
62
|
+
partitionResponses: r.readArray((r, j) => {
|
|
63
|
+
const index = r.readInt32();
|
|
64
|
+
const errorCode = r.readInt16();
|
|
65
|
+
if (errorCode !== 0) {
|
|
66
|
+
errors.push([`/responses/${i}/partition_responses/${j}`, errorCode]);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
index,
|
|
70
|
+
errorCode,
|
|
71
|
+
baseOffset: r.readInt64(),
|
|
72
|
+
logAppendTimeMs: r.readInt64(),
|
|
73
|
+
logStartOffset: r.readInt64(),
|
|
74
|
+
recordErrors: [],
|
|
75
|
+
errorMessage: null
|
|
76
|
+
};
|
|
77
|
+
}, false, false)
|
|
78
|
+
};
|
|
79
|
+
return topicResponse;
|
|
80
|
+
}, false, false),
|
|
81
|
+
throttleTimeMs: reader.readInt32()
|
|
82
|
+
};
|
|
83
|
+
if (errors.length) {
|
|
84
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
85
|
+
}
|
|
86
|
+
return response;
|
|
87
|
+
}
|
|
88
|
+
export const api = createAPI(0, 7, createRequest, parseResponse, false, false);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type NullableString } from '../../protocol/definitions.ts';
|
|
2
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
3
|
+
import { type CreateRecordsBatchOptions, type MessageRecord } from '../../protocol/records.ts';
|
|
4
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
5
|
+
export type ProduceRequest = Parameters<typeof createRequest>;
|
|
6
|
+
export interface ProduceResponsePartitionRecordError {
|
|
7
|
+
batchIndex: number;
|
|
8
|
+
batchIndexErrorMessage: NullableString;
|
|
9
|
+
}
|
|
10
|
+
export interface ProduceResponsePartition {
|
|
11
|
+
index: number;
|
|
12
|
+
errorCode: number;
|
|
13
|
+
baseOffset: bigint;
|
|
14
|
+
logAppendTimeMs: bigint;
|
|
15
|
+
logStartOffset: bigint;
|
|
16
|
+
recordErrors: ProduceResponsePartitionRecordError[];
|
|
17
|
+
errorMessage: NullableString;
|
|
18
|
+
}
|
|
19
|
+
export interface ProduceResponseTopic {
|
|
20
|
+
name: string;
|
|
21
|
+
partitionResponses: ProduceResponsePartition[];
|
|
22
|
+
}
|
|
23
|
+
export interface ProduceResponse {
|
|
24
|
+
responses: ProduceResponseTopic[];
|
|
25
|
+
throttleTimeMs: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function createRequest(acks: number | undefined, timeout: number | undefined, topicData: MessageRecord[], options?: Partial<CreateRecordsBatchOptions>): Writer;
|
|
28
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ProduceResponse;
|
|
29
|
+
export declare const api: import("../definitions.ts").API<[acks: number | undefined, timeout: number | undefined, topicData: MessageRecord[], options?: Partial<CreateRecordsBatchOptions> | undefined], boolean | ProduceResponse>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { createRecordsBatch } from "../../protocol/records.js";
|
|
3
|
+
import { Writer } from "../../protocol/writer.js";
|
|
4
|
+
import { groupByProperty } from "../../utils.js";
|
|
5
|
+
import { createAPI } from "../definitions.js";
|
|
6
|
+
import { ProduceAcks } from "../enumerations.js";
|
|
7
|
+
/*
|
|
8
|
+
Produce Request (Version: 8) => transactional_id acks timeout_ms [topic_data]
|
|
9
|
+
transactional_id => NULLABLE_STRING
|
|
10
|
+
acks => INT16
|
|
11
|
+
timeout_ms => INT32
|
|
12
|
+
topic_data => name [partition_data]
|
|
13
|
+
name => STRING
|
|
14
|
+
partition_data => index records
|
|
15
|
+
index => INT32
|
|
16
|
+
records => RECORDS
|
|
17
|
+
*/
|
|
18
|
+
export function createRequest(acks = 1, timeout = 0, topicData, options = {}) {
|
|
19
|
+
// Normalize the messages
|
|
20
|
+
const now = BigInt(Date.now());
|
|
21
|
+
for (const message of topicData) {
|
|
22
|
+
if (typeof message.partition === 'undefined') {
|
|
23
|
+
message.partition = 0;
|
|
24
|
+
}
|
|
25
|
+
if (typeof message.timestamp === 'undefined') {
|
|
26
|
+
message.timestamp = now;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const writer = Writer.create()
|
|
30
|
+
.appendString(options.transactionalId, false)
|
|
31
|
+
.appendInt16(acks)
|
|
32
|
+
.appendInt32(timeout)
|
|
33
|
+
.appendArray(groupByProperty(topicData, 'topic'), (w, [topic, messages]) => {
|
|
34
|
+
w.appendString(topic, false).appendArray(groupByProperty(messages, 'partition'), (w, [partition, messages]) => {
|
|
35
|
+
const records = createRecordsBatch(messages, options);
|
|
36
|
+
w.appendInt32(partition).appendInt32(records.length).appendFrom(records);
|
|
37
|
+
}, false, false);
|
|
38
|
+
}, false, false);
|
|
39
|
+
if (acks === ProduceAcks.NO_RESPONSE) {
|
|
40
|
+
writer.context.noResponse = true;
|
|
41
|
+
}
|
|
42
|
+
return writer;
|
|
43
|
+
}
|
|
44
|
+
/*
|
|
45
|
+
Produce Response (Version: 8) => [responses] throttle_time_ms
|
|
46
|
+
responses => name [partition_responses]
|
|
47
|
+
name => STRING
|
|
48
|
+
partition_responses => index error_code base_offset log_append_time_ms log_start_offset [record_errors] error_message
|
|
49
|
+
index => INT32
|
|
50
|
+
error_code => INT16
|
|
51
|
+
base_offset => INT64
|
|
52
|
+
log_append_time_ms => INT64
|
|
53
|
+
log_start_offset => INT64
|
|
54
|
+
record_errors => batch_index batch_index_error_message
|
|
55
|
+
batch_index => INT32
|
|
56
|
+
batch_index_error_message => NULLABLE_STRING
|
|
57
|
+
error_message => NULLABLE_STRING
|
|
58
|
+
throttle_time_ms => INT32
|
|
59
|
+
*/
|
|
60
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
61
|
+
const errors = [];
|
|
62
|
+
const response = {
|
|
63
|
+
responses: reader.readArray((r, i) => {
|
|
64
|
+
const topicResponse = {
|
|
65
|
+
name: r.readString(false),
|
|
66
|
+
partitionResponses: r.readArray((r, j) => {
|
|
67
|
+
const index = r.readInt32();
|
|
68
|
+
const errorCode = r.readInt16();
|
|
69
|
+
if (errorCode !== 0) {
|
|
70
|
+
errors.push([`/responses/${i}/partition_responses/${j}`, errorCode]);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
index,
|
|
74
|
+
errorCode,
|
|
75
|
+
baseOffset: r.readInt64(),
|
|
76
|
+
logAppendTimeMs: r.readInt64(),
|
|
77
|
+
logStartOffset: r.readInt64(),
|
|
78
|
+
recordErrors: r.readArray((r, k) => {
|
|
79
|
+
const recordError = {
|
|
80
|
+
batchIndex: r.readInt32(),
|
|
81
|
+
batchIndexErrorMessage: r.readNullableString(false)
|
|
82
|
+
};
|
|
83
|
+
if (recordError.batchIndexErrorMessage) {
|
|
84
|
+
errors.push([`/responses/${i}/partition_responses/${j}/record_errors/${k}`, -1]);
|
|
85
|
+
}
|
|
86
|
+
return recordError;
|
|
87
|
+
}, false, false),
|
|
88
|
+
errorMessage: r.readNullableString(false)
|
|
89
|
+
};
|
|
90
|
+
}, false, false)
|
|
91
|
+
};
|
|
92
|
+
return topicResponse;
|
|
93
|
+
}, false, false),
|
|
94
|
+
throttleTimeMs: reader.readInt32()
|
|
95
|
+
};
|
|
96
|
+
if (errors.length) {
|
|
97
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
98
|
+
}
|
|
99
|
+
return response;
|
|
100
|
+
}
|
|
101
|
+
export const api = createAPI(0, 8, createRequest, parseResponse, false, false);
|
|
@@ -364,18 +364,22 @@ export class Admin extends Base {
|
|
|
364
364
|
};
|
|
365
365
|
for (const member of raw.members) {
|
|
366
366
|
const reader = Reader.from(member.memberMetadata);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
367
|
+
let memberMetadata;
|
|
368
|
+
let memberAssignments;
|
|
369
|
+
if (reader.remaining > 0) {
|
|
370
|
+
memberMetadata = {
|
|
371
|
+
version: reader.readInt16(),
|
|
372
|
+
topics: reader.readArray(r => r.readString(false), false, false),
|
|
373
|
+
metadata: reader.readBytes(false)
|
|
374
|
+
};
|
|
375
|
+
reader.reset(member.memberAssignment);
|
|
376
|
+
reader.skip(2); // Ignore Version information
|
|
377
|
+
memberAssignments = reader.readMap(r => {
|
|
378
|
+
const topic = r.readString(false);
|
|
379
|
+
return [topic, { topic, partitions: reader.readArray(r => r.readInt32(), false, false) }];
|
|
380
|
+
}, false, false);
|
|
381
|
+
reader.readBytes(); // Ignore the user data
|
|
382
|
+
}
|
|
379
383
|
group.members.set(member.memberId, {
|
|
380
384
|
id: member.memberId,
|
|
381
385
|
groupInstanceId: member.groupInstanceId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AlterClientQuotasRequestEntry } from '../../apis/admin/alter-client-quotas-v1.ts';
|
|
2
|
-
import { type DescribeClientQuotasRequestComponent } from '../../apis/admin/describe-client-quotas-v0.ts';
|
|
3
|
-
import { type DescribeLogDirsResponse, type DescribeLogDirsResponseResult, type DescribeLogDirsRequestTopic } from '../../apis/admin/describe-log-dirs-v4.ts';
|
|
4
2
|
import { type CreateTopicsRequestTopicConfig } from '../../apis/admin/create-topics-v7.ts';
|
|
3
|
+
import { type DescribeClientQuotasRequestComponent } from '../../apis/admin/describe-client-quotas-v0.ts';
|
|
4
|
+
import { type DescribeLogDirsRequestTopic, type DescribeLogDirsResponse, type DescribeLogDirsResponseResult } from '../../apis/admin/describe-log-dirs-v4.ts';
|
|
5
5
|
import { type ConsumerGroupState } from '../../apis/enumerations.ts';
|
|
6
6
|
import { type NullableString } from '../../protocol/definitions.ts';
|
|
7
7
|
import { type BaseOptions } from '../base/types.ts';
|
|
@@ -22,8 +22,8 @@ export interface GroupMember {
|
|
|
22
22
|
groupInstanceId: NullableString;
|
|
23
23
|
clientId: string;
|
|
24
24
|
clientHost: string;
|
|
25
|
-
metadata
|
|
26
|
-
assignments
|
|
25
|
+
metadata?: Omit<ExtendedGroupProtocolSubscription, 'memberId'>;
|
|
26
|
+
assignments?: Map<string, GroupAssignment>;
|
|
27
27
|
}
|
|
28
28
|
export interface GroupBase {
|
|
29
29
|
id: string;
|
|
@@ -23,7 +23,6 @@ export declare const kClosed: unique symbol;
|
|
|
23
23
|
export declare const kListApis: unique symbol;
|
|
24
24
|
export declare const kMetadata: unique symbol;
|
|
25
25
|
export declare const kCheckNotClosed: unique symbol;
|
|
26
|
-
export declare const kClearMetadata: unique symbol;
|
|
27
26
|
export declare const kPerformWithRetry: unique symbol;
|
|
28
27
|
export declare const kPerformDeduplicated: unique symbol;
|
|
29
28
|
export declare const kValidateOptions: unique symbol;
|
|
@@ -63,7 +62,7 @@ export declare class Base<OptionsType extends BaseOptions = BaseOptions> extends
|
|
|
63
62
|
[kListApis](callback: CallbackWithPromise<ApiVersionsResponseApi[]>): void;
|
|
64
63
|
[kMetadata](options: MetadataOptions, callback: CallbackWithPromise<ClusterMetadata>): void;
|
|
65
64
|
[kCheckNotClosed](callback: CallbackWithPromise<any>): boolean;
|
|
66
|
-
|
|
65
|
+
clearMetadata(): void;
|
|
67
66
|
[kPerformWithRetry]<ReturnType>(operationId: string, operation: (callback: Callback<ReturnType>) => void, callback: CallbackWithPromise<ReturnType>, attempt?: number, errors?: Error[], shouldSkipRetry?: (e: Error) => boolean): void | Promise<ReturnType>;
|
|
68
67
|
[kPerformDeduplicated]<ReturnType>(operationId: string, operation: (callback: CallbackWithPromise<ReturnType>) => void, callback: CallbackWithPromise<ReturnType>): void | Promise<ReturnType>;
|
|
69
68
|
[kGetApi]<RequestArguments extends Array<unknown>, ResponseType>(name: string, callback: Callback<API<RequestArguments, ResponseType>>): void;
|