ClientGrpcProxy

  
class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
  constructor(options: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)
  protected logger: Logger
  protected clients: Map<string, any>
  protected url: string
  protected grpcClients: []
  protected options: GrpcOptions['options']
  getService<T extends {}>(name: string): T
  getClientByServiceName<T = unknown>(name: string): T
  createClientByServiceName(name: string)
  getKeepaliveOptions()
  createServiceMethod(client: any, methodName: string): (...args: unknown[]) => Observable<unknown>
  createStreamServiceMethod(client: unknown, methodName: string): (...args: any[]) => Observable<any>
  createUnaryServiceMethod(client: any, methodName: string): (...args: any[]) => Observable<any>
  createClients(): any[]
  loadProto(): any
  lookupPackage(root: any, packageName: string)
  close()
  connect(): Promise<any>
  send<TResult = any, TInput = any>(pattern: any, data: TInput): Observable<TResult>
  protected getClient(name: string): any
  protected publish(packet: any, callback: (packet: any) => any): any
  protected dispatchEvent(packet: any): Promise<any>

  // 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: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)

Parameters

Option Type Description
options { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...

Properties

Property Description
protected logger: Logger Read-only.
protected clients: Map<string, any> Read-only.
protected url: string Read-only.
protected grpcClients: []
protected options: GrpcOptions['options'] Read-only. Declared in constructor.

Methods

getService()


getService<T extends {}>(name: string): T

Parameters

Option Type Description
name string

Returns

T

getClientByServiceName()


getClientByServiceName<T = unknown>(name: string): T

Parameters

Option Type Description
name string

Returns

T

createClientByServiceName()


createClientByServiceName(name: string)

Parameters

Option Type Description
name string

getKeepaliveOptions()


getKeepaliveOptions()

Parameters

There are no parameters.

createServiceMethod()


createServiceMethod(client: any, methodName: string): (...args: unknown[]) => Observable<unknown>

Parameters

Option Type Description
client any
methodName string

Returns

(...args: unknown[]) => Observable<unknown>

createStreamServiceMethod()


createStreamServiceMethod(client: unknown, methodName: string): (...args: any[]) => Observable<any>

Parameters

Option Type Description
client unknown
methodName string

Returns

(...args: any[]) => Observable<any>

createUnaryServiceMethod()


createUnaryServiceMethod(client: any, methodName: string): (...args: any[]) => Observable<any>

Parameters

Option Type Description
client any
methodName string

Returns

(...args: any[]) => Observable<any>

createClients()


createClients(): any[]

Parameters

There are no parameters.

Returns

any[]

loadProto()


loadProto(): any

Parameters

There are no parameters.

Returns

any

lookupPackage()


lookupPackage(root: any, packageName: string)

Parameters

Option Type Description
root any
packageName string

close()


close()

Parameters

There are no parameters.

connect()


connect(): Promise<any>

Parameters

There are no parameters.

Returns

Promise<any>

send()


send<TResult = any, TInput = any>(pattern: any, data: TInput): Observable<TResult>

Parameters

Option Type Description
pattern any
data TInput

Returns

Observable<TResult>

getClient()


protected getClient(name: string): any

Parameters

Option Type Description
name string

Returns

any

publish()


protected publish(packet: any, callback: (packet: any) => any): any

Parameters

Option Type Description
packet any
callback (packet: any) => any

Returns

any

dispatchEvent()


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

Parameters

Option Type Description
packet any

Returns

Promise<any>