@nestjs/microservices
Version:
Microservices for NestJS: message and event handlers over Kafka, RabbitMQ, NATS, Redis, MQTT, gRPC or TCP.
69 lines (68 loc) • 3.21 kB
TypeScript
import { RedisContext } from '../ctx-host/index.js';
import { RedisEvents, RedisStatus } from '../events/redis.events.js';
import { RedisOptions, TransportId } from '../interfaces/index.js';
import { Server } from './server.js';
type Redis = any;
/**
* @publicApi
*/
export declare class ServerRedis extends Server<RedisEvents, RedisStatus> {
protected readonly options: Required<RedisOptions>['options'];
transportId: TransportId;
protected subClient: Redis;
protected pubClient: Redis;
protected isManuallyClosed: boolean;
protected wasInitialConnectionSuccessful: boolean;
protected pendingEventListeners: Array<{
event: keyof RedisEvents;
callback: RedisEvents[keyof RedisEvents];
}>;
constructor(options: Required<RedisOptions>['options']);
listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>;
start(callback?: () => void): void;
bindEvents(subClient: Redis, pubClient: Redis): Promise<void>;
close(): Promise<void>;
private stopReceivingMessages;
private quitClient;
createRedisClient(): Promise<Redis>;
getMessageHandler(pub: Redis): (channel: string, pattern: string, buffer: string) => Promise<any>;
handleMessage(channel: string, buffer: string, pub: Redis, pattern: string): Promise<any>;
/**
* With wildcards, the sender of a request chooses the channel it publishes
* the request to among those a pattern matches, and "*" matches a run of
* any length. Every reply is published on a copy of that channel
* ("<channel>.reply"), as many times as the handler emits.
*/
protected assertWildcardChannelLength(subscription: string, channel: string): void;
/**
* With wildcards, whether a message handler is subscribed to the channel a
* request was published to as well. Only a subscription to that very
* channel is found: Redis' glob-style matching is not reproduced here.
*/
private isAnsweredByMessageHandler;
/**
* With wildcards, a subscription such as "users.*" also matches the channels
* this server replies on ("users.created.reply"). Those replies are skipped
* unless the subscription itself targets reply channels.
*/
private isOwnReply;
getPublisher(pub: Redis, pattern: any, id: string, ctx: RedisContext): (response: any) => any;
parseMessage(content: any): Record<string, any>;
getRequestPattern(pattern: string): string;
getReplyPattern(pattern: string): string;
registerErrorListener(client: any): void;
registerReconnectListener(client: {
on: (event: string, fn: () => void) => void;
}): void;
registerReadyListener(client: {
on: (event: string, fn: () => void) => void;
}): void;
registerEndListener(client: {
on: (event: string, fn: () => void) => void;
}): void;
getClientOptions(): Partial<RedisOptions['options']>;
createRetryStrategy(times: number): undefined | number | void;
unwrap<T>(): T;
on<EventKey extends keyof RedisEvents = keyof RedisEvents, EventCallback extends RedisEvents[EventKey] = RedisEvents[EventKey]>(event: EventKey, callback: EventCallback): void;
}
export {};