UNPKG

2.27 kBTypeScriptView Raw
1import { Logger } from '@nestjs/common/services/logger.service';
2import { KafkaContext } from '../ctx-host';
3import { Transport } from '../enums';
4import { BrokersFunction, Consumer, EachMessagePayload, Kafka, Message, Producer, RecordMetadata } from '../external/kafka.interface';
5import { KafkaParser } from '../helpers';
6import { CustomTransportStrategy, KafkaOptions, OutgoingResponse, ReadPacket } from '../interfaces';
7import { Server } from './server';
8export declare class ServerKafka extends Server implements CustomTransportStrategy {
9 protected readonly options: KafkaOptions['options'];
10 readonly transportId = Transport.KAFKA;
11 protected logger: Logger;
12 protected client: Kafka;
13 protected consumer: Consumer;
14 protected producer: Producer;
15 protected parser: KafkaParser;
16 protected brokers: string[] | BrokersFunction;
17 protected clientId: string;
18 protected groupId: string;
19 constructor(options: KafkaOptions['options']);
20 listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>;
21 close(): Promise<void>;
22 start(callback: () => void): Promise<void>;
23 createClient<T = any>(): T;
24 bindEvents(consumer: Consumer): Promise<void>;
25 getMessageHandler(): (payload: EachMessagePayload) => Promise<any>;
26 getPublisher(replyTopic: string, replyPartition: string, correlationId: string): (data: any) => Promise<RecordMetadata[]>;
27 handleMessage(payload: EachMessagePayload): Promise<any>;
28 private combineStreamsAndThrowIfRetriable;
29 sendMessage(message: OutgoingResponse, replyTopic: string, replyPartition: string, correlationId: string): Promise<RecordMetadata[]>;
30 assignIsDisposedHeader(outgoingResponse: OutgoingResponse, outgoingMessage: Message): void;
31 assignErrorHeader(outgoingResponse: OutgoingResponse, outgoingMessage: Message): void;
32 assignCorrelationIdHeader(correlationId: string, outgoingMessage: Message): void;
33 assignReplyPartition(replyPartition: string, outgoingMessage: Message): void;
34 handleEvent(pattern: string, packet: ReadPacket, context: KafkaContext): Promise<any>;
35 protected initializeSerializer(options: KafkaOptions['options']): void;
36 protected initializeDeserializer(options: KafkaOptions['options']): void;
37}