class ServerRedis extends Server {
constructor(options: { host?: string; port?: number; retryAttempts?: number; retryDelay?: number; wildcards?: boolean; serializer?: Serializer<any, any>; deserializer?: Deserializer<any, any>; } & IORedisOptions)
transportId: Transport.REDIS
protected subClient: Redis
protected pubClient: Redis
protected isManuallyClosed: false
protected wasInitialConnectionSuccessful: false
protected pendingEventListeners: Array<{...}
protected options: Required<RedisOptions>['options']
listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void)
start(callback?: () => void)
bindEvents(subClient: any, pubClient: any)
close()
createRedisClient(): Redis
getMessageHandler(pub: any)
handleMessage(channel: string, buffer: string, pub: any, pattern: string)
getPublisher(pub: any, pattern: any, id: string)
parseMessage(content: any): Record<string, any>
getRequestPattern(pattern: string): string
getReplyPattern(pattern: string): string
registerErrorListener(client: any)
registerReconnectListener(client: { on: (event: string, fn: () => void) => void; })
registerReadyListener(client: { on: (event: string, fn: () => void) => void; })
registerEndListener(client: { on: (event: string, fn: () => 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)
transportId?: Transport | symbol
protected messageHandlers: Map<string, MessageHandler>
protected logger: LoggerService
protected serializer: ConsumerSerializer
protected deserializer: ConsumerDeserializer
protected _status$: ReplaySubject<Status>
status: Observable<Status>
abstract on<EventKey extends keyof EventsMap = keyof EventsMap, EventCallback extends EventsMap[EventKey] = EventsMap[EventKey]>(event: EventKey, callback: EventCallback): any
abstract unwrap<T>(): T
abstract listen(callback: (...optionalParams: unknown[]) => any): any
abstract close(): any
addHandler(pattern: any, callback: MessageHandler<any, any, any>, isEventHandler: boolean = false, extras: Record<string, any> = {})
getHandlers(): Map<string, MessageHandler>
getHandlerByPattern(pattern: string): MessageHandler | null
send(stream$: Observable<any>, respond: (data: WritePacket<any>) => void | Promise<unknown>): Subscription
handleEvent(pattern: string, packet: ReadPacket<any>, context: BaseRpcContext<unknown[]>): Promise<any>
transformToObservable(resultOrDeferred: any)
getOptionsProp<Options extends MicroserviceOptions['options'], Attribute extends keyof Options, DefaultValue extends Options[Attribute] = Options[Attribute]>(obj: Options, prop: Attribute, defaultValue: DefaultValue = undefined as DefaultValue)
protected handleError(error: string)
protected loadPackage<T = any>(name: string, ctx: string, loader?: Function): T
protected initializeSerializer(options: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)
protected initializeDeserializer(options: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)
protected getRouteFromPattern(pattern: string): string
protected normalizePattern(pattern: MsPattern): string
}
Constructor
constructor(options: { host?: string; port?: number; retryAttempts?: number; retryDelay?: number; wildcards?: boolean; serializer?: Serializer<any, any>; deserializer?: Deserializer<any, any>; } & IORedisOptions)
Parameters
Option |
Type |
Description |
options
|
{ host?: string; port?: number; retryAttempts?: number; retryDelay?: number; wildcards?: boolean; serializer?: Serializer; deserializer?: Deserializer; } & IORedisOptions |
|
|
Properties
Property |
Description |
transportId: Transport.REDIS
|
Read-only.
|
protected subClient: Redis
|
|
protected pubClient: Redis
|
|
protected isManuallyClosed: false
|
|
protected wasInitialConnectionSuccessful: false
|
|
protected pendingEventListeners: Array<{
event: keyof RedisEvents;
callback: RedisEvents[keyof RedisEvents];
}>
|
|
protected options: Required<RedisOptions>['options']
|
Read-only.
Declared in constructor.
|
Methods
listen()
|
listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void)
Parameters
Option |
Type |
Description |
callback
|
(err?: unknown, ...optionalParams: unknown[]) => void |
|
|
start()
|
start(callback?: () => void)
Parameters
Option |
Type |
Description |
callback
|
() => void |
Optional. Default is undefined .
|
|
bindEvents()
|
bindEvents(subClient: any, pubClient: any)
Parameters
Option |
Type |
Description |
subClient
|
any |
|
pubClient
|
any |
|
|
close()
|
close()
Parameters
There are no parameters.
|
createRedisClient()
|
createRedisClient(): Redis
Parameters
There are no parameters.
Returns
Redis
|
getMessageHandler()
|
getMessageHandler(pub: any)
Parameters
Option |
Type |
Description |
pub
|
any |
|
|
handleMessage()
|
handleMessage(channel: string, buffer: string, pub: any, pattern: string)
Parameters
|
getPublisher()
|
getPublisher(pub: any, pattern: any, id: string)
Parameters
Option |
Type |
Description |
pub
|
any |
|
pattern
|
any |
|
id
|
string |
|
|
parseMessage()
|
parseMessage(content: any): Record<string, any>
Parameters
Option |
Type |
Description |
content
|
any |
|
Returns
Record<string, any>
|
getRequestPattern()
|
getRequestPattern(pattern: string): string
Parameters
Option |
Type |
Description |
pattern
|
string |
|
Returns
string
|
getReplyPattern()
|
getReplyPattern(pattern: string): string
Parameters
Option |
Type |
Description |
pattern
|
string |
|
Returns
string
|
registerErrorListener()
|
registerErrorListener(client: any)
Parameters
Option |
Type |
Description |
client
|
any |
|
|
registerReconnectListener()
|
registerReconnectListener(client: { on: (event: string, fn: () => void) => void; })
Parameters
Option |
Type |
Description |
client
|
object |
|
|
registerReadyListener()
|
registerReadyListener(client: { on: (event: string, fn: () => void) => void; })
Parameters
Option |
Type |
Description |
client
|
object |
|
|
registerEndListener()
|
registerEndListener(client: { on: (event: string, fn: () => void) => void; })
Parameters
Option |
Type |
Description |
client
|
object |
|
|
getClientOptions()
|
getClientOptions(): Partial<RedisOptions['options']>
Parameters
There are no parameters.
Returns
Partial<RedisOptions['options']>
|
createRetryStrategy()
|
createRetryStrategy(times: number): undefined | number | void
Parameters
Option |
Type |
Description |
times
|
number |
|
Returns
undefined | number | void
|
unwrap()
|
unwrap<T>(): T
Parameters
There are no parameters.
Returns
T
|
on()
|
on<EventKey extends keyof RedisEvents = keyof RedisEvents, EventCallback extends RedisEvents[EventKey] = RedisEvents[EventKey]>(event: EventKey, callback: EventCallback)
Parameters
Option |
Type |
Description |
event
|
EventKey |
|
callback
|
EventCallback |
|
|