import { type ProducerGlobalConfig } from "@confluentinc/kafka-javascript"; /** * Reference: https://kafka.js.org/docs/producing#producing-messages */ export interface KafkaProducerSendOptions { acks?: number; timeout?: number; retries?: number; allowAutoTopicCreation?: boolean; maxInFlightRequests?: number; } /** * Creates a KafkaProducer which opens a persistent TCP connection. * This class is thread-safe so your service should re-use one instance. * * Example: * ```ts * kafka = new KafkaProducer(...) * await kafka.send(topic, events) * // Non-blocking: * // void kafka.send(topic, events).catch((e) => console.error(e)) * ``` */ export declare class KafkaProducer { private producer; private connectPromise?; constructor(options: { /** * A descriptive name for your service. Example: "storage-server" */ producerName: string; /** * A comma-separated list of `host[:port]` Kafka servers. */ kafkaServers: string; username: string; password: string; /** * Configuration for the Kafka producer. */ config?: ProducerGlobalConfig; }); /** * Connects the producer. Can be called explicitly at the start of your service, or will be called automatically when sending messages. * * A cached promise is used so this function is safe to call more than once and concurrently. */ connect(): Promise; /** * Send messages to a Kafka topic. * This method may throw. To call this non-blocking: * ```ts * void kafka.send(topic, events).catch((e) => console.error(e)) * ``` * * @param topic * @param messages */ send(topic: string, messages: Record[]): Promise; /** * Disconnects KafkaProducer. * Useful when shutting down the service to flush in-flight events. */ disconnect(): Promise; } //# sourceMappingURL=kafka.d.ts.map