From c083ea5eda72b08e8457a5e8b0cef891afdf58ca Mon Sep 17 00:00:00 2001 From: Anatoly Tokalov Date: Fri, 27 Jul 2018 20:43:04 +0300 Subject: [PATCH] [@types/kafka-node]: add missind Admin class and loadMetadataForTopics getListGroups and describeGroups methods (#27475) --- types/kafka-node/index.d.ts | 9 +++++++++ types/kafka-node/kafka-node-tests.ts | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/types/kafka-node/index.d.ts b/types/kafka-node/index.d.ts index 71d1fd6728..2f44a7e767 100644 --- a/types/kafka-node/index.d.ts +++ b/types/kafka-node/index.d.ts @@ -9,6 +9,7 @@ export class Client { constructor(connectionString: string, clientId?: string, options?: ZKOptions, noBatchOptions?: AckBatchOptions, sslOptions?: any); close(cb?: () => void): void; + loadMetadataForTopics(topics: string[], cb: (error: TopicsNotExistError | any, data: any) => any): void; topicExists(topics: string[], cb: (error?: TopicsNotExistError | any) => any): void; refreshMetadata(topics: string[], cb?: (error?: any) => any): void; sendOffsetCommitV2Request(group: string, generationId: number, memberId: string, commits: OffsetCommitRequest[], cb: (error: any, data: any) => any): void; @@ -20,6 +21,8 @@ export class Client { export class KafkaClient extends Client { constructor(options?: KafkaClientOptions); connect(): void; + getListGroups(cb: (error: any, data: any) => any): void; + describeGroups(consumerGroups: any, cb: (error: any, data: any) => any): void; } export class Producer { @@ -93,6 +96,12 @@ export class KeyedMessage { constructor(key: string, value: string | Buffer); } +export class Admin { + constructor(kafkaClient: KafkaClient); + listGroups(cb: (error: any, data: any) => any): void; + describeGroups(consumerGroups: any, cb: (error: any, data: any) => any): void; +} + // # Interfaces export interface Message { diff --git a/types/kafka-node/kafka-node-tests.ts b/types/kafka-node/kafka-node-tests.ts index 0ffe5d86b7..1e433172ae 100644 --- a/types/kafka-node/kafka-node-tests.ts +++ b/types/kafka-node/kafka-node-tests.ts @@ -14,6 +14,8 @@ const optionsClient = new kafka.Client('localhost:2181/', 'sendMessage', { }); optionsClient.topicExists(['topic'], (error: any) => { }); +optionsClient.loadMetadataForTopics(['topic'], (error: any, data: any) => { +}); optionsClient.refreshMetadata(['topic'], (error: any) => { }); optionsClient.close(); @@ -48,6 +50,11 @@ const optionsProducer = new kafka.Producer(basicClient, { partitionerType: 0 }); +optionsKafkaClient.getListGroups((error: any, data: any) => { +}); +optionsKafkaClient.describeGroups([], (error: any, data: any) => { +}); + const producer = new kafka.Producer(basicClient); producer.on('error', (error: Error) => { }); @@ -265,3 +272,9 @@ offset.fetchLatestOffsets(['t'], (err, offsets) => { }); offset.fetchEarliestOffsets(['t'], (err, offsets) => { }); + +const admin = new kafka.Admin(basicKafkaClient); +admin.listGroups((err, data) => { +}); +admin.describeGroups({}, (err, data) => { +});