@nestjs/microservices
Version:
Microservices for NestJS: message and event handlers over Kafka, RabbitMQ, NATS, Redis, MQTT, gRPC or TCP.
52 lines (51 loc) • 1.55 kB
TypeScript
import { Consumer, KafkaMessage, Producer } from '../external/kafka.interface.js';
import { PacketMetadata } from '../interfaces/packet.interface.js';
import { BaseRpcContext } from './base-rpc.context.js';
type KafkaContextArgs = [
message: KafkaMessage,
partition: number,
topic: string,
consumer: Consumer,
heartbeat: () => Promise<void>,
producer: Producer,
metadata?: PacketMetadata
];
/**
* @publicApi
*/
export declare class KafkaContext extends BaseRpcContext<KafkaContextArgs> {
constructor(args: KafkaContextArgs);
/**
* Returns the reference to the original message.
*/
getMessage(): KafkaMessage;
/**
* Returns the partition.
*/
getPartition(): number;
/**
* Returns the name of the topic.
*/
getTopic(): string;
/**
* Returns the Kafka consumer reference.
*/
getConsumer(): Consumer;
/**
* Returns the Kafka heartbeat callback.
*/
getHeartbeat(): () => Promise<void>;
/**
* Returns the Kafka producer reference,
*/
getProducer(): Producer;
/**
* Returns the message headers as packet metadata: what the client attached
* to the packet, and every other header with a single, UTF-8 text value,
* as it arrived (the headers of `getMessage()` are decoded, so a value that
* reads as JSON is an object there). A header with several values or with
* binary content is only available through `getMessage()`.
*/
getMetadata(): PacketMetadata | undefined;
}
export {};