@platformatic/kafka 0.1.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/LICENSE +201 -0
- package/README.md +270 -0
- package/dist/apis/admin/alter-client-quotas.d.ts +33 -0
- package/dist/apis/admin/alter-client-quotas.js +64 -0
- package/dist/apis/admin/alter-configs.d.ts +26 -0
- package/dist/apis/admin/alter-configs.js +57 -0
- package/dist/apis/admin/alter-partition-reassignments.d.ts +30 -0
- package/dist/apis/admin/alter-partition-reassignments.js +68 -0
- package/dist/apis/admin/alter-partition.d.ts +39 -0
- package/dist/apis/admin/alter-partition.js +87 -0
- package/dist/apis/admin/alter-replica-log-dirs.d.ts +26 -0
- package/dist/apis/admin/alter-replica-log-dirs.js +55 -0
- package/dist/apis/admin/alter-user-scram-credentials.d.ts +27 -0
- package/dist/apis/admin/alter-user-scram-credentials.js +60 -0
- package/dist/apis/admin/consumer-group-describe.d.ts +41 -0
- package/dist/apis/admin/consumer-group-describe.js +103 -0
- package/dist/apis/admin/create-acls.d.ts +24 -0
- package/dist/apis/admin/create-acls.js +55 -0
- package/dist/apis/admin/create-delegation-token.d.ts +24 -0
- package/dist/apis/admin/create-delegation-token.js +54 -0
- package/dist/apis/admin/create-partitions.d.ts +24 -0
- package/dist/apis/admin/create-partitions.js +54 -0
- package/dist/apis/admin/create-topics.d.ts +42 -0
- package/dist/apis/admin/create-topics.js +86 -0
- package/dist/apis/admin/delete-acls.d.ts +36 -0
- package/dist/apis/admin/delete-acls.js +82 -0
- package/dist/apis/admin/delete-groups.d.ts +14 -0
- package/dist/apis/admin/delete-groups.js +40 -0
- package/dist/apis/admin/delete-records.d.ts +27 -0
- package/dist/apis/admin/delete-records.js +59 -0
- package/dist/apis/admin/delete-topics.d.ts +21 -0
- package/dist/apis/admin/delete-topics.js +50 -0
- package/dist/apis/admin/describe-acls.d.ts +25 -0
- package/dist/apis/admin/describe-acls.js +66 -0
- package/dist/apis/admin/describe-client-quotas.d.ts +30 -0
- package/dist/apis/admin/describe-client-quotas.js +57 -0
- package/dist/apis/admin/describe-cluster.d.ts +23 -0
- package/dist/apis/admin/describe-cluster.js +50 -0
- package/dist/apis/admin/describe-configs.d.ts +38 -0
- package/dist/apis/admin/describe-configs.js +85 -0
- package/dist/apis/admin/describe-delegation-token.d.ts +31 -0
- package/dist/apis/admin/describe-delegation-token.js +62 -0
- package/dist/apis/admin/describe-groups.d.ts +28 -0
- package/dist/apis/admin/describe-groups.js +67 -0
- package/dist/apis/admin/describe-log-dirs.d.ts +32 -0
- package/dist/apis/admin/describe-log-dirs.js +75 -0
- package/dist/apis/admin/describe-producers.d.ts +33 -0
- package/dist/apis/admin/describe-producers.js +70 -0
- package/dist/apis/admin/describe-quorum.d.ts +50 -0
- package/dist/apis/admin/describe-quorum.js +116 -0
- package/dist/apis/admin/describe-topic-partitions.d.ts +42 -0
- package/dist/apis/admin/describe-topic-partitions.js +94 -0
- package/dist/apis/admin/describe-transactions.d.ts +24 -0
- package/dist/apis/admin/describe-transactions.js +59 -0
- package/dist/apis/admin/describe-user-scram-credentials.d.ts +26 -0
- package/dist/apis/admin/describe-user-scram-credentials.js +62 -0
- package/dist/apis/admin/envelope.d.ts +10 -0
- package/dist/apis/admin/envelope.js +32 -0
- package/dist/apis/admin/expire-delegation-token.d.ts +11 -0
- package/dist/apis/admin/expire-delegation-token.js +29 -0
- package/dist/apis/admin/incremental-alter-configs.d.ts +27 -0
- package/dist/apis/admin/incremental-alter-configs.js +58 -0
- package/dist/apis/admin/index.d.ts +37 -0
- package/dist/apis/admin/index.js +37 -0
- package/dist/apis/admin/list-groups.d.ts +18 -0
- package/dist/apis/admin/list-groups.js +43 -0
- package/dist/apis/admin/list-partition-reassignments.d.ts +27 -0
- package/dist/apis/admin/list-partition-reassignments.js +56 -0
- package/dist/apis/admin/list-transactions.d.ts +18 -0
- package/dist/apis/admin/list-transactions.js +45 -0
- package/dist/apis/admin/offset-delete.d.ts +26 -0
- package/dist/apis/admin/offset-delete.js +59 -0
- package/dist/apis/admin/renew-delegation-token.d.ts +11 -0
- package/dist/apis/admin/renew-delegation-token.js +29 -0
- package/dist/apis/admin/unregister-broker.d.ts +12 -0
- package/dist/apis/admin/unregister-broker.js +28 -0
- package/dist/apis/admin/update-features.d.ts +23 -0
- package/dist/apis/admin/update-features.js +60 -0
- package/dist/apis/consumer/consumer-group-heartbeat.d.ts +27 -0
- package/dist/apis/consumer/consumer-group-heartbeat.js +70 -0
- package/dist/apis/consumer/fetch.d.ts +46 -0
- package/dist/apis/consumer/fetch.js +121 -0
- package/dist/apis/consumer/heartbeat.d.ts +11 -0
- package/dist/apis/consumer/heartbeat.js +34 -0
- package/dist/apis/consumer/index.d.ts +9 -0
- package/dist/apis/consumer/index.js +9 -0
- package/dist/apis/consumer/join-group.d.ts +27 -0
- package/dist/apis/consumer/join-group.js +71 -0
- package/dist/apis/consumer/leave-group.d.ts +22 -0
- package/dist/apis/consumer/leave-group.js +57 -0
- package/dist/apis/consumer/list-offsets.d.ts +30 -0
- package/dist/apis/consumer/list-offsets.js +68 -0
- package/dist/apis/consumer/offset-commit.d.ts +29 -0
- package/dist/apis/consumer/offset-commit.js +68 -0
- package/dist/apis/consumer/offset-fetch.d.ts +37 -0
- package/dist/apis/consumer/offset-fetch.js +81 -0
- package/dist/apis/consumer/sync-group.d.ts +18 -0
- package/dist/apis/consumer/sync-group.js +49 -0
- package/dist/apis/definitions.d.ts +16 -0
- package/dist/apis/definitions.js +12 -0
- package/dist/apis/enumerations.d.ts +114 -0
- package/dist/apis/enumerations.js +78 -0
- package/dist/apis/index.d.ts +8 -0
- package/dist/apis/index.js +10 -0
- package/dist/apis/metadata/api-versions.d.ts +17 -0
- package/dist/apis/metadata/api-versions.js +41 -0
- package/dist/apis/metadata/find-coordinator.d.ts +19 -0
- package/dist/apis/metadata/find-coordinator.js +50 -0
- package/dist/apis/metadata/index.d.ts +3 -0
- package/dist/apis/metadata/index.js +3 -0
- package/dist/apis/metadata/metadata.d.ts +37 -0
- package/dist/apis/metadata/metadata.js +92 -0
- package/dist/apis/producer/add-offsets-to-txn.d.ts +10 -0
- package/dist/apis/producer/add-offsets-to-txn.js +34 -0
- package/dist/apis/producer/add-partitions-to-txn.d.ts +34 -0
- package/dist/apis/producer/add-partitions-to-txn.js +79 -0
- package/dist/apis/producer/end-txn.d.ts +10 -0
- package/dist/apis/producer/end-txn.js +34 -0
- package/dist/apis/producer/index.d.ts +6 -0
- package/dist/apis/producer/index.js +6 -0
- package/dist/apis/producer/init-producer-id.d.ts +21 -0
- package/dist/apis/producer/init-producer-id.js +38 -0
- package/dist/apis/producer/produce.d.ts +29 -0
- package/dist/apis/producer/produce.js +104 -0
- package/dist/apis/producer/txn-offset-commit.d.ts +29 -0
- package/dist/apis/producer/txn-offset-commit.js +77 -0
- package/dist/apis/security/index.d.ts +2 -0
- package/dist/apis/security/index.js +2 -0
- package/dist/apis/security/sasl-authenticate.d.ts +15 -0
- package/dist/apis/security/sasl-authenticate.js +30 -0
- package/dist/apis/security/sasl-handshake.d.ts +10 -0
- package/dist/apis/security/sasl-handshake.js +28 -0
- package/dist/apis/telemetry/get-telemetry-subscriptions.d.ts +18 -0
- package/dist/apis/telemetry/get-telemetry-subscriptions.js +46 -0
- package/dist/apis/telemetry/index.d.ts +3 -0
- package/dist/apis/telemetry/index.js +3 -0
- package/dist/apis/telemetry/list-client-metrics-resources.d.ts +14 -0
- package/dist/apis/telemetry/list-client-metrics-resources.js +32 -0
- package/dist/apis/telemetry/push-telemetry.d.ts +10 -0
- package/dist/apis/telemetry/push-telemetry.js +36 -0
- package/dist/clients/admin/admin.d.ts +18 -0
- package/dist/clients/admin/admin.js +322 -0
- package/dist/clients/admin/index.d.ts +3 -0
- package/dist/clients/admin/index.js +3 -0
- package/dist/clients/admin/options.d.ts +135 -0
- package/dist/clients/admin/options.js +81 -0
- package/dist/clients/admin/types.d.ts +56 -0
- package/dist/clients/admin/types.js +1 -0
- package/dist/clients/base/base.d.ts +48 -0
- package/dist/clients/base/base.js +242 -0
- package/dist/clients/base/index.d.ts +3 -0
- package/dist/clients/base/index.js +3 -0
- package/dist/clients/base/options.d.ts +115 -0
- package/dist/clients/base/options.js +59 -0
- package/dist/clients/base/types.d.ts +38 -0
- package/dist/clients/base/types.js +1 -0
- package/dist/clients/callbacks.d.ts +8 -0
- package/dist/clients/callbacks.js +42 -0
- package/dist/clients/consumer/consumer.d.ts +33 -0
- package/dist/clients/consumer/consumer.js +767 -0
- package/dist/clients/consumer/index.d.ts +5 -0
- package/dist/clients/consumer/index.js +5 -0
- package/dist/clients/consumer/messages-stream.d.ts +56 -0
- package/dist/clients/consumer/messages-stream.js +404 -0
- package/dist/clients/consumer/options.d.ts +521 -0
- package/dist/clients/consumer/options.js +177 -0
- package/dist/clients/consumer/topics-map.d.ts +8 -0
- package/dist/clients/consumer/topics-map.js +48 -0
- package/dist/clients/consumer/types.d.ts +74 -0
- package/dist/clients/consumer/types.js +11 -0
- package/dist/clients/index.d.ts +6 -0
- package/dist/clients/index.js +6 -0
- package/dist/clients/producer/index.d.ts +3 -0
- package/dist/clients/producer/index.js +3 -0
- package/dist/clients/producer/options.d.ts +122 -0
- package/dist/clients/producer/options.js +47 -0
- package/dist/clients/producer/producer.d.ts +13 -0
- package/dist/clients/producer/producer.js +272 -0
- package/dist/clients/producer/types.d.ts +29 -0
- package/dist/clients/producer/types.js +1 -0
- package/dist/clients/serde.d.ts +40 -0
- package/dist/clients/serde.js +49 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.js +160 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -0
- package/dist/network/connection-pool.d.ts +11 -0
- package/dist/network/connection-pool.js +101 -0
- package/dist/network/connection.d.ts +49 -0
- package/dist/network/connection.js +319 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.js +2 -0
- package/dist/protocol/apis.d.ts +2 -0
- package/dist/protocol/apis.js +191 -0
- package/dist/protocol/compression.d.ts +70 -0
- package/dist/protocol/compression.js +114 -0
- package/dist/protocol/crc32c.d.ts +2 -0
- package/dist/protocol/crc32c.js +83 -0
- package/dist/protocol/definitions.d.ts +12 -0
- package/dist/protocol/definitions.js +11 -0
- package/dist/protocol/dynamic-buffer.d.ts +65 -0
- package/dist/protocol/dynamic-buffer.js +557 -0
- package/dist/protocol/errors.d.ts +8 -0
- package/dist/protocol/errors.js +908 -0
- package/dist/protocol/index.d.ts +14 -0
- package/dist/protocol/index.js +14 -0
- package/dist/protocol/murmur2.d.ts +1 -0
- package/dist/protocol/murmur2.js +55 -0
- package/dist/protocol/reader.d.ts +58 -0
- package/dist/protocol/reader.js +296 -0
- package/dist/protocol/records.d.ts +110 -0
- package/dist/protocol/records.js +149 -0
- package/dist/protocol/sasl/plain.d.ts +3 -0
- package/dist/protocol/sasl/plain.js +3 -0
- package/dist/protocol/sasl/scram-sha.d.ts +28 -0
- package/dist/protocol/sasl/scram-sha.js +104 -0
- package/dist/protocol/varint.d.ts +12 -0
- package/dist/protocol/varint.js +36 -0
- package/dist/protocol/writer.d.ts +48 -0
- package/dist/protocol/writer.js +223 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +127 -0
- package/package.json +75 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
GetTelemetrySubscriptions Request (Version: 0) => client_instance_id TAG_BUFFER
|
|
6
|
+
client_instance_id => UUID
|
|
7
|
+
*/
|
|
8
|
+
export function createRequest(clientInstanceId) {
|
|
9
|
+
return Writer.create().appendUUID(clientInstanceId).appendTaggedFields();
|
|
10
|
+
}
|
|
11
|
+
/*
|
|
12
|
+
GetTelemetrySubscriptions Response (Version: 0) => throttle_time_ms error_code client_instance_id subscription_id [accepted_compression_types] push_interval_ms telemetry_max_bytes delta_temporality [requested_metrics] TAG_BUFFER
|
|
13
|
+
throttle_time_ms => INT32
|
|
14
|
+
error_code => INT16
|
|
15
|
+
client_instance_id => UUID
|
|
16
|
+
subscription_id => INT32
|
|
17
|
+
accepted_compression_types => INT8
|
|
18
|
+
push_interval_ms => INT32
|
|
19
|
+
telemetry_max_bytes => INT32
|
|
20
|
+
delta_temporality => BOOLEAN
|
|
21
|
+
requested_metrics => COMPACT_STRING
|
|
22
|
+
*/
|
|
23
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
24
|
+
const errors = [];
|
|
25
|
+
const throttleTimeMs = reader.readInt32();
|
|
26
|
+
const errorCode = reader.readInt16();
|
|
27
|
+
if (errorCode !== 0) {
|
|
28
|
+
errors.push(['', errorCode]);
|
|
29
|
+
}
|
|
30
|
+
const response = {
|
|
31
|
+
throttleTimeMs,
|
|
32
|
+
errorCode,
|
|
33
|
+
clientInstanceId: reader.readUUID(),
|
|
34
|
+
subscriptionId: reader.readInt32(),
|
|
35
|
+
acceptedCompressionTypes: reader.readArray(r => r.readInt8(), true, false),
|
|
36
|
+
pushIntervalMs: reader.readInt32(),
|
|
37
|
+
telemetryMaxBytes: reader.readInt32(),
|
|
38
|
+
deltaTemporality: reader.readBoolean(),
|
|
39
|
+
requestedMetrics: reader.readArray(r => r.readString(), true, false)
|
|
40
|
+
};
|
|
41
|
+
if (errors.length) {
|
|
42
|
+
throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
|
|
43
|
+
}
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
export const api = createAPI(71, 0, createRequest, parseResponse);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
2
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
3
|
+
export type ListClientMetricsResourcesRequest = Parameters<typeof createRequest>;
|
|
4
|
+
export interface ListClientMetricsResourcesResource {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ListClientMetricsResourcesResponse {
|
|
8
|
+
throttleTimeMs: number;
|
|
9
|
+
errorCode: number;
|
|
10
|
+
clientMetricsResources: ListClientMetricsResourcesResource[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createRequest(): Writer;
|
|
13
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListClientMetricsResourcesResponse;
|
|
14
|
+
export declare const api: import("../definitions.ts").API<[], ListClientMetricsResourcesResponse>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
ListClientMetricsResources Request (Version: 0) => TAG_BUFFER
|
|
6
|
+
*/
|
|
7
|
+
export function createRequest() {
|
|
8
|
+
return Writer.create().appendTaggedFields();
|
|
9
|
+
}
|
|
10
|
+
/*
|
|
11
|
+
ListClientMetricsResources Response (Version: 0) => throttle_time_ms error_code [client_metrics_resources] TAG_BUFFER
|
|
12
|
+
throttle_time_ms => INT32
|
|
13
|
+
error_code => INT16
|
|
14
|
+
client_metrics_resources => name TAG_BUFFER
|
|
15
|
+
name => COMPACT_STRING
|
|
16
|
+
*/
|
|
17
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
18
|
+
const response = {
|
|
19
|
+
throttleTimeMs: reader.readInt32(),
|
|
20
|
+
errorCode: reader.readInt16(),
|
|
21
|
+
clientMetricsResources: reader.readArray(r => {
|
|
22
|
+
return {
|
|
23
|
+
name: r.readString()
|
|
24
|
+
};
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
if (response.errorCode !== 0) {
|
|
28
|
+
throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
|
|
29
|
+
}
|
|
30
|
+
return response;
|
|
31
|
+
}
|
|
32
|
+
export const api = createAPI(74, 0, createRequest, parseResponse);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Reader } from '../../protocol/reader.ts';
|
|
2
|
+
import { Writer } from '../../protocol/writer.ts';
|
|
3
|
+
export type PushTelemetryRequest = Parameters<typeof createRequest>;
|
|
4
|
+
export interface PushTelemetryResponse {
|
|
5
|
+
throttleTimeMs: number;
|
|
6
|
+
errorCode: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createRequest(clientInstanceId: string, subscriptionId: number, terminating: boolean, compressionType: number, metrics: Buffer): Writer;
|
|
9
|
+
export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): PushTelemetryResponse;
|
|
10
|
+
export declare const api: import("../definitions.ts").API<[clientInstanceId: string, subscriptionId: number, terminating: boolean, compressionType: number, metrics: Buffer<ArrayBufferLike>], PushTelemetryResponse>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ResponseError } from "../../errors.js";
|
|
2
|
+
import { Writer } from "../../protocol/writer.js";
|
|
3
|
+
import { createAPI } from "../definitions.js";
|
|
4
|
+
/*
|
|
5
|
+
PushTelemetry Request (Version: 0) => client_instance_id subscription_id terminating compression_type metrics TAG_BUFFER
|
|
6
|
+
client_instance_id => UUID
|
|
7
|
+
subscription_id => INT32
|
|
8
|
+
terminating => BOOLEAN
|
|
9
|
+
compression_type => INT8
|
|
10
|
+
metrics => COMPACT_BYTES
|
|
11
|
+
*/
|
|
12
|
+
export function createRequest(clientInstanceId, subscriptionId, terminating, compressionType, metrics) {
|
|
13
|
+
return Writer.create()
|
|
14
|
+
.appendUUID(clientInstanceId)
|
|
15
|
+
.appendInt32(subscriptionId)
|
|
16
|
+
.appendBoolean(terminating)
|
|
17
|
+
.appendInt8(compressionType)
|
|
18
|
+
.appendBytes(metrics)
|
|
19
|
+
.appendTaggedFields();
|
|
20
|
+
}
|
|
21
|
+
/*
|
|
22
|
+
PushTelemetry Response (Version: 0) => throttle_time_ms error_code TAG_BUFFER
|
|
23
|
+
throttle_time_ms => INT32
|
|
24
|
+
error_code => INT16
|
|
25
|
+
*/
|
|
26
|
+
export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
|
|
27
|
+
const response = {
|
|
28
|
+
throttleTimeMs: reader.readInt32(),
|
|
29
|
+
errorCode: reader.readInt16()
|
|
30
|
+
};
|
|
31
|
+
if (response.errorCode !== 0) {
|
|
32
|
+
throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
export const api = createAPI(72, 0, createRequest, parseResponse);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Callback } from '../../apis/definitions.ts';
|
|
2
|
+
import { Base } from '../base/base.ts';
|
|
3
|
+
import { type CallbackWithPromise } from '../callbacks.ts';
|
|
4
|
+
import { type AdminOptions, type CreatedTopic, type CreateTopicsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DescribeGroupsOptions, type Group, type GroupBase, type ListGroupsOptions } from './types.ts';
|
|
5
|
+
export declare class Admin extends Base<AdminOptions> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(options: AdminOptions);
|
|
8
|
+
createTopics(options: CreateTopicsOptions, callback: Callback<CreatedTopic[]>): void;
|
|
9
|
+
createTopics(options: CreateTopicsOptions): Promise<CreatedTopic[]>;
|
|
10
|
+
deleteTopics(options: DeleteTopicsOptions, callback: CallbackWithPromise<void>): void;
|
|
11
|
+
deleteTopics(options: DeleteTopicsOptions): Promise<void>;
|
|
12
|
+
listGroups(options: ListGroupsOptions, callback: CallbackWithPromise<Map<string, GroupBase>>): void;
|
|
13
|
+
listGroups(options?: ListGroupsOptions): Promise<Map<string, GroupBase>>;
|
|
14
|
+
describeGroups(options: DescribeGroupsOptions, callback: CallbackWithPromise<Map<string, Group>>): void;
|
|
15
|
+
describeGroups(options: DescribeGroupsOptions): Promise<Map<string, Group>>;
|
|
16
|
+
deleteGroups(options: DeleteGroupsOptions, callback: CallbackWithPromise<void>): void;
|
|
17
|
+
deleteGroups(options: DeleteGroupsOptions): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { api as createTopicsV7 } from "../../apis/admin/create-topics.js";
|
|
2
|
+
import { api as deleteGroupsV2 } from "../../apis/admin/delete-groups.js";
|
|
3
|
+
import { api as deleteTopicsV6 } from "../../apis/admin/delete-topics.js";
|
|
4
|
+
import { api as describeGroupsV5 } from "../../apis/admin/describe-groups.js";
|
|
5
|
+
import { api as listGroupsV5 } from "../../apis/admin/list-groups.js";
|
|
6
|
+
import { FindCoordinatorKeyTypes } from "../../apis/enumerations.js";
|
|
7
|
+
import { api as findCoordinatorV6 } from "../../apis/metadata/find-coordinator.js";
|
|
8
|
+
import { Reader } from "../../protocol/reader.js";
|
|
9
|
+
import { Base, kBootstrapBrokers, kCheckNotClosed, kConnections, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kValidateOptions } from "../base/base.js";
|
|
10
|
+
import { createPromisifiedCallback, kCallbackPromise, runConcurrentCallbacks } from "../callbacks.js";
|
|
11
|
+
import { createTopicsOptionsValidator, deleteGroupsOptionsValidator, deleteTopicsOptionsValidator, describeGroupsOptionsValidator, listGroupsOptionsValidator } from "./options.js";
|
|
12
|
+
export class Admin extends Base {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(options);
|
|
15
|
+
}
|
|
16
|
+
createTopics(options, callback) {
|
|
17
|
+
if (!callback) {
|
|
18
|
+
callback = createPromisifiedCallback();
|
|
19
|
+
}
|
|
20
|
+
if (this[kCheckNotClosed](callback)) {
|
|
21
|
+
return callback[kCallbackPromise];
|
|
22
|
+
}
|
|
23
|
+
const validationError = this[kValidateOptions](options, createTopicsOptionsValidator, '/options', false);
|
|
24
|
+
if (validationError) {
|
|
25
|
+
callback(validationError, undefined);
|
|
26
|
+
return callback[kCallbackPromise];
|
|
27
|
+
}
|
|
28
|
+
this.#createTopics(options, callback);
|
|
29
|
+
return callback[kCallbackPromise];
|
|
30
|
+
}
|
|
31
|
+
deleteTopics(options, callback) {
|
|
32
|
+
if (!callback) {
|
|
33
|
+
callback = createPromisifiedCallback();
|
|
34
|
+
}
|
|
35
|
+
if (this[kCheckNotClosed](callback)) {
|
|
36
|
+
return callback[kCallbackPromise];
|
|
37
|
+
}
|
|
38
|
+
const validationError = this[kValidateOptions](options, deleteTopicsOptionsValidator, '/options', false);
|
|
39
|
+
if (validationError) {
|
|
40
|
+
callback(validationError, undefined);
|
|
41
|
+
return callback[kCallbackPromise];
|
|
42
|
+
}
|
|
43
|
+
this.#deleteTopics(options, callback);
|
|
44
|
+
return callback[kCallbackPromise];
|
|
45
|
+
}
|
|
46
|
+
listGroups(options, callback) {
|
|
47
|
+
if (!callback) {
|
|
48
|
+
callback = createPromisifiedCallback();
|
|
49
|
+
}
|
|
50
|
+
if (this[kCheckNotClosed](callback)) {
|
|
51
|
+
return callback[kCallbackPromise];
|
|
52
|
+
}
|
|
53
|
+
if (!options) {
|
|
54
|
+
options = {};
|
|
55
|
+
}
|
|
56
|
+
const validationError = this[kValidateOptions](options, listGroupsOptionsValidator, '/options', false);
|
|
57
|
+
if (validationError) {
|
|
58
|
+
callback(validationError, undefined);
|
|
59
|
+
return callback[kCallbackPromise];
|
|
60
|
+
}
|
|
61
|
+
options.types ??= ['classic'];
|
|
62
|
+
this.#listGroups(options, callback);
|
|
63
|
+
return callback[kCallbackPromise];
|
|
64
|
+
}
|
|
65
|
+
describeGroups(options, callback) {
|
|
66
|
+
if (!callback) {
|
|
67
|
+
callback = createPromisifiedCallback();
|
|
68
|
+
}
|
|
69
|
+
if (this[kCheckNotClosed](callback)) {
|
|
70
|
+
return callback[kCallbackPromise];
|
|
71
|
+
}
|
|
72
|
+
const validationError = this[kValidateOptions](options, describeGroupsOptionsValidator, '/options', false);
|
|
73
|
+
if (validationError) {
|
|
74
|
+
callback(validationError, undefined);
|
|
75
|
+
return callback[kCallbackPromise];
|
|
76
|
+
}
|
|
77
|
+
this.#describeGroups(options, callback);
|
|
78
|
+
return callback[kCallbackPromise];
|
|
79
|
+
}
|
|
80
|
+
deleteGroups(options, callback) {
|
|
81
|
+
if (!callback) {
|
|
82
|
+
callback = createPromisifiedCallback();
|
|
83
|
+
}
|
|
84
|
+
if (this[kCheckNotClosed](callback)) {
|
|
85
|
+
return callback[kCallbackPromise];
|
|
86
|
+
}
|
|
87
|
+
const validationError = this[kValidateOptions](options, deleteGroupsOptionsValidator, '/options', false);
|
|
88
|
+
if (validationError) {
|
|
89
|
+
callback(validationError, undefined);
|
|
90
|
+
return callback[kCallbackPromise];
|
|
91
|
+
}
|
|
92
|
+
this.#deleteGroups(options, callback);
|
|
93
|
+
return callback[kCallbackPromise];
|
|
94
|
+
}
|
|
95
|
+
#createTopics(options, callback) {
|
|
96
|
+
const numPartitions = options.partitions ?? 1;
|
|
97
|
+
const replicationFactor = options.replicas ?? 1;
|
|
98
|
+
const assignments = [];
|
|
99
|
+
for (const { partition, brokers } of options.assignments ?? []) {
|
|
100
|
+
assignments.push({ partitionIndex: partition, brokerIds: brokers });
|
|
101
|
+
}
|
|
102
|
+
const requests = [];
|
|
103
|
+
for (const topic of options.topics) {
|
|
104
|
+
requests.push({
|
|
105
|
+
name: topic,
|
|
106
|
+
numPartitions,
|
|
107
|
+
replicationFactor,
|
|
108
|
+
assignments,
|
|
109
|
+
configs: []
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
this[kPerformDeduplicated]('createTopics', deduplicateCallback => {
|
|
113
|
+
this[kPerformWithRetry]('createTopics', retryCallback => {
|
|
114
|
+
this[kConnections].getFirstAvailable(this[kBootstrapBrokers], (error, connection) => {
|
|
115
|
+
if (error) {
|
|
116
|
+
retryCallback(error, undefined);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
createTopicsV7(connection, requests, this[kOptions].timeout, false, retryCallback);
|
|
120
|
+
});
|
|
121
|
+
}, (error, response) => {
|
|
122
|
+
if (error) {
|
|
123
|
+
deduplicateCallback(error, undefined);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const created = [];
|
|
127
|
+
for (const { name, topicId: id, numPartitions: partitions, replicationFactor: replicas, configs } of response.topics) {
|
|
128
|
+
const configuration = {};
|
|
129
|
+
for (const { name, value } of configs) {
|
|
130
|
+
configuration[name] = value;
|
|
131
|
+
}
|
|
132
|
+
created.push({ id, name, partitions, replicas, configuration });
|
|
133
|
+
}
|
|
134
|
+
deduplicateCallback(null, created);
|
|
135
|
+
}, 0);
|
|
136
|
+
}, callback);
|
|
137
|
+
}
|
|
138
|
+
#deleteTopics(options, callback) {
|
|
139
|
+
this[kPerformDeduplicated]('deleteTopics', deduplicateCallback => {
|
|
140
|
+
this[kPerformWithRetry]('deleteTopics', retryCallback => {
|
|
141
|
+
this[kConnections].getFirstAvailable(this[kBootstrapBrokers], (error, connection) => {
|
|
142
|
+
if (error) {
|
|
143
|
+
retryCallback(error, undefined);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const requests = [];
|
|
147
|
+
for (const topic of options.topics) {
|
|
148
|
+
requests.push({ name: topic });
|
|
149
|
+
}
|
|
150
|
+
deleteTopicsV6(connection, requests, this[kOptions].timeout, retryCallback);
|
|
151
|
+
});
|
|
152
|
+
}, deduplicateCallback, 0);
|
|
153
|
+
}, callback);
|
|
154
|
+
}
|
|
155
|
+
#listGroups(options, callback) {
|
|
156
|
+
// Find all the brokers in the cluster
|
|
157
|
+
this[kMetadata]({ topics: [] }, (error, metadata) => {
|
|
158
|
+
if (error) {
|
|
159
|
+
callback(error, undefined);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
runConcurrentCallbacks('Listing groups failed.', metadata.brokers, ([, broker], concurrentCallback) => {
|
|
163
|
+
this[kConnections].get(broker, (error, connection) => {
|
|
164
|
+
if (error) {
|
|
165
|
+
concurrentCallback(error, undefined);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this[kPerformWithRetry]('listGroups', retryCallback => {
|
|
169
|
+
listGroupsV5(connection, options.states ?? [], options.types, retryCallback);
|
|
170
|
+
}, concurrentCallback, 0);
|
|
171
|
+
});
|
|
172
|
+
}, (error, results) => {
|
|
173
|
+
if (error) {
|
|
174
|
+
callback(error, undefined);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const groups = new Map();
|
|
178
|
+
for (const result of results) {
|
|
179
|
+
for (const raw of result.groups) {
|
|
180
|
+
groups.set(raw.groupId, {
|
|
181
|
+
id: raw.groupId,
|
|
182
|
+
state: raw.groupState.toUpperCase(),
|
|
183
|
+
groupType: raw.groupType,
|
|
184
|
+
protocolType: raw.protocolType
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
callback(null, groups);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
#describeGroups(options, callback) {
|
|
193
|
+
this[kMetadata]({ topics: [] }, (error, metadata) => {
|
|
194
|
+
if (error) {
|
|
195
|
+
callback(error, undefined);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.#findGroupCoordinator(options.groups, (error, response) => {
|
|
199
|
+
if (error) {
|
|
200
|
+
callback(error, undefined);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// Group the groups by coordinator
|
|
204
|
+
const coordinators = new Map();
|
|
205
|
+
for (const { key: group, nodeId: node } of response.coordinators) {
|
|
206
|
+
let coordinator = coordinators.get(node);
|
|
207
|
+
if (!coordinator) {
|
|
208
|
+
coordinator = [];
|
|
209
|
+
coordinators.set(node, coordinator);
|
|
210
|
+
}
|
|
211
|
+
coordinator.push(group);
|
|
212
|
+
}
|
|
213
|
+
runConcurrentCallbacks('Describing groups failed.', coordinators, ([node, groups], concurrentCallback) => {
|
|
214
|
+
this[kConnections].get(metadata.brokers.get(node), (error, connection) => {
|
|
215
|
+
if (error) {
|
|
216
|
+
concurrentCallback(error, undefined);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this[kPerformWithRetry]('describeGroups', retryCallback => {
|
|
220
|
+
describeGroupsV5(connection, groups, options.includeAuthorizedOperations ?? false, retryCallback);
|
|
221
|
+
}, concurrentCallback, 0);
|
|
222
|
+
});
|
|
223
|
+
}, (error, results) => {
|
|
224
|
+
if (error) {
|
|
225
|
+
callback(error, undefined);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const groups = new Map();
|
|
229
|
+
for (const result of results) {
|
|
230
|
+
for (const raw of result.groups) {
|
|
231
|
+
const group = {
|
|
232
|
+
id: raw.groupId,
|
|
233
|
+
state: raw.groupState.toUpperCase(),
|
|
234
|
+
protocolType: raw.protocolType,
|
|
235
|
+
protocol: raw.protocolData,
|
|
236
|
+
members: new Map(),
|
|
237
|
+
authorizedOperations: raw.authorizedOperations
|
|
238
|
+
};
|
|
239
|
+
for (const member of raw.members) {
|
|
240
|
+
const reader = Reader.from(member.memberMetadata);
|
|
241
|
+
const memberMetadata = {
|
|
242
|
+
version: reader.readInt16(),
|
|
243
|
+
topics: reader.readArray(r => r.readString(false), false, false),
|
|
244
|
+
metadata: reader.readBytes(false)
|
|
245
|
+
};
|
|
246
|
+
reader.reset(member.memberAssignment);
|
|
247
|
+
const memberAssignments = reader.readMap(r => {
|
|
248
|
+
const topic = r.readString();
|
|
249
|
+
return [topic, { topic, partitions: reader.readArray(r => r.readInt32(), true, false) }];
|
|
250
|
+
}, true, false);
|
|
251
|
+
group.members.set(member.memberId, {
|
|
252
|
+
id: member.memberId,
|
|
253
|
+
groupInstanceId: member.groupInstanceId,
|
|
254
|
+
clientId: member.clientId,
|
|
255
|
+
clientHost: member.clientHost,
|
|
256
|
+
metadata: memberMetadata,
|
|
257
|
+
assignments: memberAssignments
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
groups.set(group.id, group);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
callback(null, groups);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
#deleteGroups(options, callback) {
|
|
269
|
+
this[kMetadata]({ topics: [] }, (error, metadata) => {
|
|
270
|
+
if (error) {
|
|
271
|
+
callback(error);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.#findGroupCoordinator(options.groups, (error, response) => {
|
|
275
|
+
if (error) {
|
|
276
|
+
callback(error);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
// Group the groups by coordinator
|
|
280
|
+
const coordinators = new Map();
|
|
281
|
+
for (const { key: group, nodeId: node } of response.coordinators) {
|
|
282
|
+
let coordinator = coordinators.get(node);
|
|
283
|
+
if (!coordinator) {
|
|
284
|
+
coordinator = [];
|
|
285
|
+
coordinators.set(node, coordinator);
|
|
286
|
+
}
|
|
287
|
+
coordinator.push(group);
|
|
288
|
+
}
|
|
289
|
+
runConcurrentCallbacks('Deleting groups failed.', coordinators, ([node, groups], concurrentCallback) => {
|
|
290
|
+
this[kConnections].get(metadata.brokers.get(node), (error, connection) => {
|
|
291
|
+
if (error) {
|
|
292
|
+
concurrentCallback(error, undefined);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this[kPerformWithRetry]('deleteGroups', retryCallback => {
|
|
296
|
+
deleteGroupsV2(connection, groups, retryCallback);
|
|
297
|
+
}, concurrentCallback, 0);
|
|
298
|
+
});
|
|
299
|
+
}, error => {
|
|
300
|
+
callback(error);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
#findGroupCoordinator(groups, callback) {
|
|
306
|
+
this[kPerformWithRetry]('findGroupCoordinator', retryCallback => {
|
|
307
|
+
this[kConnections].getFirstAvailable(this[kBootstrapBrokers], (error, connection) => {
|
|
308
|
+
if (error) {
|
|
309
|
+
retryCallback(error, undefined);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
findCoordinatorV6(connection, FindCoordinatorKeyTypes.GROUP, groups, retryCallback);
|
|
313
|
+
});
|
|
314
|
+
}, (error, response) => {
|
|
315
|
+
if (error) {
|
|
316
|
+
callback(error, undefined);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
callback(null, response);
|
|
320
|
+
}, 0);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export declare const groupsProperties: {
|
|
2
|
+
groups: {
|
|
3
|
+
type: string;
|
|
4
|
+
items: {
|
|
5
|
+
type: string;
|
|
6
|
+
pattern: string;
|
|
7
|
+
};
|
|
8
|
+
minItems: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const createTopicOptionsSchema: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
topics: {
|
|
15
|
+
type: string;
|
|
16
|
+
items: {
|
|
17
|
+
type: string;
|
|
18
|
+
pattern: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
partitions: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
replicas: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
assignments: {
|
|
28
|
+
type: string;
|
|
29
|
+
items: {
|
|
30
|
+
type: string;
|
|
31
|
+
properties: {
|
|
32
|
+
partition: {
|
|
33
|
+
type: string;
|
|
34
|
+
minimum: number;
|
|
35
|
+
};
|
|
36
|
+
brokers: {
|
|
37
|
+
type: string;
|
|
38
|
+
items: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
minItems: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
required: string[];
|
|
45
|
+
additionalProperties: boolean;
|
|
46
|
+
};
|
|
47
|
+
minItems: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
required: string[];
|
|
51
|
+
additionalProperties: boolean;
|
|
52
|
+
};
|
|
53
|
+
export declare const deleteTopicOptionsSchema: {
|
|
54
|
+
type: string;
|
|
55
|
+
properties: {
|
|
56
|
+
topics: {
|
|
57
|
+
type: string;
|
|
58
|
+
items: {
|
|
59
|
+
type: string;
|
|
60
|
+
pattern: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
required: string[];
|
|
65
|
+
additionalProperties: boolean;
|
|
66
|
+
};
|
|
67
|
+
export declare const listGroupsOptionsSchema: {
|
|
68
|
+
type: string;
|
|
69
|
+
properties: {
|
|
70
|
+
states: {
|
|
71
|
+
type: string;
|
|
72
|
+
items: {
|
|
73
|
+
type: string;
|
|
74
|
+
enum: readonly ["PREPARING_REBALANCE", "COMPLETING_REBALANCE", "STABLE", "DEAD", "EMPTY"];
|
|
75
|
+
errorMessage: string;
|
|
76
|
+
};
|
|
77
|
+
minItems: number;
|
|
78
|
+
};
|
|
79
|
+
types: {
|
|
80
|
+
type: string;
|
|
81
|
+
items: {
|
|
82
|
+
type: string;
|
|
83
|
+
pattern: string;
|
|
84
|
+
};
|
|
85
|
+
minItems: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
additionalProperties: boolean;
|
|
89
|
+
};
|
|
90
|
+
export declare const describeGroupsOptionsSchema: {
|
|
91
|
+
type: string;
|
|
92
|
+
properties: {
|
|
93
|
+
includeAuthorizedOperations: {
|
|
94
|
+
type: string;
|
|
95
|
+
};
|
|
96
|
+
groups: {
|
|
97
|
+
type: string;
|
|
98
|
+
items: {
|
|
99
|
+
type: string;
|
|
100
|
+
pattern: string;
|
|
101
|
+
};
|
|
102
|
+
minItems: number;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
required: string[];
|
|
106
|
+
additionalProperties: boolean;
|
|
107
|
+
};
|
|
108
|
+
export declare const deleteGroupsOptionsSchema: {
|
|
109
|
+
type: string;
|
|
110
|
+
properties: {
|
|
111
|
+
groups: {
|
|
112
|
+
type: string;
|
|
113
|
+
items: {
|
|
114
|
+
type: string;
|
|
115
|
+
pattern: string;
|
|
116
|
+
};
|
|
117
|
+
minItems: number;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
required: string[];
|
|
121
|
+
additionalProperties: boolean;
|
|
122
|
+
};
|
|
123
|
+
export declare const createTopicsOptionsValidator: import("ajv").ValidateFunction<{
|
|
124
|
+
[x: string]: {};
|
|
125
|
+
}>;
|
|
126
|
+
export declare const deleteTopicsOptionsValidator: import("ajv").ValidateFunction<{
|
|
127
|
+
[x: string]: {};
|
|
128
|
+
}>;
|
|
129
|
+
export declare const listGroupsOptionsValidator: import("ajv").ValidateFunction<unknown>;
|
|
130
|
+
export declare const describeGroupsOptionsValidator: import("ajv").ValidateFunction<{
|
|
131
|
+
[x: string]: {};
|
|
132
|
+
}>;
|
|
133
|
+
export declare const deleteGroupsOptionsValidator: import("ajv").ValidateFunction<{
|
|
134
|
+
[x: string]: {};
|
|
135
|
+
}>;
|