UNPKG

1.88 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 { CustomTransportStrategy, KafkaOptions, OutgoingResponse } from '../interfaces';
5import { Server } from './server';
6export declare class ServerKafka extends Server implements CustomTransportStrategy {
7 protected readonly options: KafkaOptions['options'];
8 readonly transportId = Transport.KAFKA;
9 protected logger: Logger;
10 protected client: Kafka;
11 protected consumer: Consumer;
12 protected producer: Producer;
13 protected brokers: string[] | BrokersFunction;
14 protected clientId: string;
15 protected groupId: string;
16 constructor(options: KafkaOptions['options']);
17 listen(callback: () => void): Promise<void>;
18 close(): Promise<void>;
19 start(callback: () => void): Promise<void>;
20 createClient<T = any>(): T;
21 bindEvents(consumer: Consumer): Promise<void>;
22 getMessageHandler(): (payload: EachMessagePayload) => Promise<any>;
23 getPublisher(replyTopic: string, replyPartition: string, correlationId: string): (data: any) => Promise<RecordMetadata[]>;
24 handleMessage(payload: EachMessagePayload): Promise<any>;
25 sendMessage(message: OutgoingResponse, replyTopic: string, replyPartition: string, correlationId: string): Promise<RecordMetadata[]>;
26 assignIsDisposedHeader(outgoingResponse: OutgoingResponse, outgoingMessage: Message): void;
27 assignErrorHeader(outgoingResponse: OutgoingResponse, outgoingMessage: Message): void;
28 assignCorrelationIdHeader(correlationId: string, outgoingMessage: Message): void;
29 assignReplyPartition(replyPartition: string, outgoingMessage: Message): void;
30 protected initializeSerializer(options: KafkaOptions['options']): void;
31}