UNPKG

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