UNPKG

2.3 kBTypeScriptView Raw
1import { Logger } from '@nestjs/common/services/logger.service';
2import { BrokersFunction, Consumer, ConsumerGroupJoinEvent, EachMessagePayload, Kafka, Producer, TopicPartitionOffsetAndMetadata } from '../external/kafka.interface';
3import { KafkaParser } from '../helpers';
4import { KafkaOptions, OutgoingEvent, ReadPacket, WritePacket } from '../interfaces';
5import { ClientProxy } from './client-proxy';
6import { Observable } from 'rxjs';
7/**
8 * @publicApi
9 */
10export declare class ClientKafka extends ClientProxy {
11 protected readonly options: KafkaOptions['options'];
12 protected logger: Logger;
13 protected client: Kafka | null;
14 protected consumer: Consumer | null;
15 protected producer: Producer | null;
16 protected parser: KafkaParser | null;
17 protected initialized: Promise<void> | null;
18 protected responsePatterns: string[];
19 protected consumerAssignments: {
20 [key: string]: number;
21 };
22 protected brokers: string[] | BrokersFunction;
23 protected clientId: string;
24 protected groupId: string;
25 protected producerOnlyMode: boolean;
26 constructor(options: KafkaOptions['options']);
27 subscribeToResponseOf(pattern: any): void;
28 close(): Promise<void>;
29 connect(): Promise<Producer>;
30 bindTopics(): Promise<void>;
31 createClient<T = any>(): T;
32 createResponseCallback(): (payload: EachMessagePayload) => any;
33 getConsumerAssignments(): {
34 [key: string]: number;
35 };
36 emitBatch<TResult = any, TInput = any>(pattern: any, data: {
37 messages: TInput[];
38 }): Observable<TResult>;
39 commitOffsets(topicPartitions: TopicPartitionOffsetAndMetadata[]): Promise<void>;
40 protected dispatchBatchEvent<TInput = any>(packets: ReadPacket<{
41 messages: TInput[];
42 }>): Promise<any>;
43 protected dispatchEvent(packet: OutgoingEvent): Promise<any>;
44 protected getReplyTopicPartition(topic: string): string;
45 protected publish(partialPacket: ReadPacket, callback: (packet: WritePacket) => any): () => void;
46 protected getResponsePatternName(pattern: string): string;
47 protected setConsumerAssignments(data: ConsumerGroupJoinEvent): void;
48 protected initializeSerializer(options: KafkaOptions['options']): void;
49 protected initializeDeserializer(options: KafkaOptions['options']): void;
50}