ClientNats

  
class ClientNats extends ClientProxy {
  constructor(options: { [key: string]: any; headers?: Record<string, string>; authenticator?: any; debug?: boolean; ignoreClusterUpdates?: boolean; inboxPrefix?: string; encoding?: string; name?: string; user?: string; ... 28 more ...; tokenHandler?: any; })
  protected logger: Logger
  protected natsClient: Client
  protected options: NatsOptions['options']
  close()
  connect(): Promise<any>
  createClient(): Promise<Client>
  handleStatusUpdates(client: Client)
  createSubscriptionHandler(packet: ReadPacket<any> & PacketId, callback: (packet: WritePacket<any>) => any)
  protected publish(partialPacket: ReadPacket<any>, callback: (packet: WritePacket<any>) => any): () => void
  protected dispatchEvent(packet: ReadPacket<any>): Promise<any>
  protected initializeSerializer(options: { [key: string]: any; headers?: Record<string, string>; authenticator?: any; debug?: boolean; ignoreClusterUpdates?: boolean; inboxPrefix?: string; encoding?: string; name?: string; user?: string; ... 28 more ...; tokenHandler?: any; })
  protected initializeDeserializer(options: { [key: string]: any; headers?: Record<string, string>; authenticator?: any; debug?: boolean; ignoreClusterUpdates?: boolean; inboxPrefix?: string; encoding?: string; name?: string; user?: string; ... 28 more ...; tokenHandler?: any; })
  protected mergeHeaders<THeaders = any>(requestHeaders?: THeaders)

  // inherited from nest/packages/microservices/ClientProxy
  protected routingMap: Map<string, Function>
  protected serializer: ProducerSerializer
  protected deserializer: ProducerDeserializer
  abstract connect(): Promise<any>
  abstract close(): any
  send<TResult = any, TInput = any>(pattern: any, data: TInput): Observable<TResult>
  emit<TResult = any, TInput = any>(pattern: any, data: TInput): Observable<TResult>
  protected abstract publish(packet: ReadPacket<any>, callback: (packet: WritePacket<any>) => void): () => void
  protected abstract dispatchEvent<T = any>(packet: ReadPacket<any>): Promise<T>
  protected createObserver<T>(observer: Observer<T>): (packet: WritePacket) => void
  protected serializeError(err: any): any
  protected serializeResponse(response: any): any
  protected assignPacketId(packet: ReadPacket<any>): ReadPacket & PacketId
  protected connect$(instance: any, errorEvent: string = ERROR_EVENT, connectEvent: string = CONNECT_EVENT): Observable<any>
  protected getOptionsProp<T extends ClientOptions['options'], K extends keyof T>(obj: T, prop: K, defaultValue: T[K] = undefined)
  protected normalizePattern(pattern: MsPattern): string
  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...)
}

Constructor


constructor(options: { [key: string]: any; headers?: Record<string, string>; authenticator?: any; debug?: boolean; ignoreClusterUpdates?: boolean; inboxPrefix?: string; encoding?: string; name?: string; user?: string; ... 28 more ...; tokenHandler?: any; })

Parameters

Option Type Description
options object

Properties

Property Description
protected logger: Logger Read-only.
protected natsClient: Client
protected options: NatsOptions['options'] Read-only. Declared in constructor.

Methods

close()


close()

Parameters

There are no parameters.

connect()


connect(): Promise<any>

Parameters

There are no parameters.

Returns

Promise<any>

createClient()


createClient(): Promise<Client>

Parameters

There are no parameters.

Returns

Promise<Client>

handleStatusUpdates()


handleStatusUpdates(client: Client)

Parameters

Option Type Description
client Client

createSubscriptionHandler()


createSubscriptionHandler(packet: ReadPacket<any> & PacketId, callback: (packet: WritePacket<any>) => any)

Parameters

Option Type Description
packet ReadPacket & PacketId
callback (packet: WritePacket) => any

publish()


protected publish(partialPacket: ReadPacket<any>, callback: (packet: WritePacket<any>) => any): () => void

Parameters

Option Type Description
partialPacket ReadPacket
callback (packet: WritePacket) => any

Returns

() => void

dispatchEvent()


protected dispatchEvent(packet: ReadPacket<any>): Promise<any>

Parameters

Option Type Description
packet ReadPacket

Returns

Promise<any>

initializeSerializer()


protected initializeSerializer(options: { [key: string]: any; headers?: Record<string, string>; authenticator?: any; debug?: boolean; ignoreClusterUpdates?: boolean; inboxPrefix?: string; encoding?: string; name?: string; user?: string; ... 28 more ...; tokenHandler?: any; })

Parameters

Option Type Description
options object

initializeDeserializer()


protected initializeDeserializer(options: { [key: string]: any; headers?: Record<string, string>; authenticator?: any; debug?: boolean; ignoreClusterUpdates?: boolean; inboxPrefix?: string; encoding?: string; name?: string; user?: string; ... 28 more ...; tokenHandler?: any; })

Parameters

Option Type Description
options object

mergeHeaders()


protected mergeHeaders<THeaders = any>(requestHeaders?: THeaders)

Parameters

Option Type Description
requestHeaders THeaders

Optional. Default is undefined.