UNPKG

2.29 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';
8/**
9 * @publicApi
10 */
11export declare class ServerKafka extends Server implements CustomTransportStrategy {
12 protected readonly options: KafkaOptions['options'];
13 readonly transportId = Transport.KAFKA;
14 protected logger: Logger;
15 protected client: Kafka;
16 protected consumer: Consumer;
17 protected producer: Producer;
18 protected parser: KafkaParser;
19 protected brokers: string[] | BrokersFunction;
20 protected clientId: string;
21 protected groupId: string;
22 constructor(options: KafkaOptions['options']);
23 listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>;
24 close(): Promise<void>;
25 start(callback: () => void): Promise<void>;
26 createClient<T = any>(): T;
27 bindEvents(consumer: Consumer): Promise<void>;
28 getMessageHandler(): (payload: EachMessagePayload) => Promise<any>;
29 getPublisher(replyTopic: string, replyPartition: string, correlationId: string): (data: any) => Promise<RecordMetadata[]>;
30 handleMessage(payload: EachMessagePayload): Promise<any>;
31 private combineStreamsAndThrowIfRetriable;
32 sendMessage(message: OutgoingResponse, replyTopic: string, replyPartition: string, correlationId: string): Promise<RecordMetadata[]>;
33 assignIsDisposedHeader(outgoingResponse: OutgoingResponse, outgoingMessage: Message): void;
34 assignErrorHeader(outgoingResponse: OutgoingResponse, outgoingMessage: Message): void;
35 assignCorrelationIdHeader(correlationId: string, outgoingMessage: Message): void;
36 assignReplyPartition(replyPartition: string, outgoingMessage: Message): void;
37 handleEvent(pattern: string, packet: ReadPacket, context: KafkaContext): Promise<any>;
38 protected initializeSerializer(options: KafkaOptions['options']): void;
39 protected initializeDeserializer(options: KafkaOptions['options']): void;
40}