/** * @fileoverview Kafka admin operations and topic management * @description Handles topic creation, listing, and administrative operations */ import { KafkaConfig } from "../interface/kafka.interface"; import { KafkaConnectionManager } from "./connection-manager"; import { KafkaProducerManager } from "./producer-manager"; /** * Manages Kafka administrative operations and topic lifecycle. * * @description This class handles all administrative operations including: * - Topic creation with configurable partitions and replication * - Topic listing and discovery * - Topic map management for efficient lookups * - Integration with producer for topic update notifications * * @example * ```typescript * const admin = KafkaAdminManager.getInstance(connection, config); * await admin.createTopic('user-events', 3, 2); // 3 partitions, 2 replicas * const topics = await admin.listTopics(); * ``` */ export declare class KafkaAdminManager { private readonly kafkaConnection; private topicMap; private logger; private _config; private producer; private static _instance; /** * Creates a new KafkaAdminManager instance. * * @param kafkaConnection - Kafka connection manager * @param config - Kafka configuration * @private */ constructor(kafkaConnection: KafkaConnectionManager, config: KafkaConfig); /** * Gets or creates the singleton instance of KafkaAdminManager. * * @param connection - Kafka connection manager instance * @param config - Kafka configuration * @returns The singleton KafkaAdminManager instance */ static getInstance(connection: KafkaConnectionManager, config: KafkaConfig): KafkaAdminManager; /** * Sets the producer manager for sending topic update notifications. * * @param producer - Producer manager instance * * @description This creates a circular dependency between admin and producer * to enable topic update notifications when new topics are created. */ setProducer(producer: KafkaProducerManager): void; /** * Creates a new Kafka topic if it doesn't already exist. * * @param topicName - Name of the topic to create * @param numPartitions - Number of partitions (defaults to config value or 1) * @param replicationFactor - Replication factor (defaults to config value or 1) * @returns Promise that resolves when topic creation is complete * @throws Error if topic creation fails * * @description Creates a topic with the specified configuration. If the topic * already exists in the topic map, the operation is skipped. Upon successful * creation, sends a notification to the topic-updates topic for dynamic subscription. * * @example * ```typescript * // Create with defaults * await admin.createTopic('user-events'); * * // Create with custom settings * await admin.createTopic('high-throughput-topic', 10, 3); * ``` */ createTopic(topicName: string, numPartitions?: number, replicationFactor?: number): Promise; /** * Lists all topics in the Kafka cluster. * * @returns Promise resolving to array of topic names * * @description Retrieves a list of all topics currently available in the * Kafka cluster. This includes both user-created topics and system topics. */ listTopics(): Promise; createTopicPublic(topic: string, serviceName: string, entityId: string, numPartitions?: number, replicationFactor?: number): Promise; sendPublicTopicUpdate(topic: string, serviceName: string, entityId: string): Promise; /** * Populates the internal topic map with existing topics. * * @returns Promise that resolves when topic map is populated * * @description Called during initialization to build an internal cache * of existing topics. This prevents unnecessary topic creation attempts * and improves performance by avoiding duplicate API calls. */ populateTopicMapOnStart(): Promise; } //# sourceMappingURL=admin-manager.d.ts.map