class ServerGrpc extends Server implements CustomTransportStrategy {
constructor(options: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)
transportId: Transport.GRPC
listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void)
start(callback?: () => void)
bindEvents()
getServiceNames(grpcPkg: any): {...}
createService(grpcService: any, name: string)
createPattern(service: string, methodName: string, streaming: GrpcMethodStreamingType): string
createServiceMethod(methodHandler: Function, protoNativeHandler: any, streamType: GrpcMethodStreamingType): Function
createUnaryServiceMethod(methodHandler: Function): Function
createStreamServiceMethod(methodHandler: Function): Function
createRequestStreamMethod(methodHandler: Function, isResponseStream: boolean)
createStreamCallMethod(methodHandler: Function, isResponseStream: boolean)
close()
deserialize(obj: any): any
addHandler(pattern: unknown, callback: MessageHandler<any, any, any>, isEventHandler: boolean = false)
createClient(): Promise<any>
lookupPackage(root: any, packageName: string)
loadProto(): any
protected messageHandlers: Map<string, MessageHandler>
protected logger: LoggerService
protected serializer: ConsumerSerializer
protected deserializer: ConsumerDeserializer
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>) => unknown): Subscription
handleEvent(pattern: string, packet: ReadPacket<any>, context: BaseRpcContext<unknown[]>): Promise<any>
transformToObservable(resultOrDeferred: any)
getOptionsProp<T extends MicroserviceOptions['options'], K extends keyof T>(obj: T, prop: K, defaultValue: T[K] = undefined)
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: { 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 |
transportId: Transport.GRPC
|
Read-only.
|
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()
Parameters
There are no parameters.
|
getServiceNames()
|
|
Will return all of the services along with their fully namespaced
names as an array of objects.
This method initiates recursive scan of grpcPkg object
|
getServiceNames(grpcPkg: any): {
name: string;
service: any;
}[]
Parameters
| Option |
Type |
Description |
grpcPkg
|
any |
|
Returns
{
name: string;
service: any;
}[]
|
createService()
|
|
Will create service mapping from gRPC generated Object to handlers
defined with @GrpcMethod or @GrpcStreamMethod annotations
|
createService(grpcService: any, name: string)
Parameters
| Option |
Type |
Description |
grpcService
|
any |
|
name
|
string |
|
|
createPattern()
|
|
Will create a string of a JSON serialized format
|
createPattern(service: string, methodName: string, streaming: GrpcMethodStreamingType): string
Parameters
| Option |
Type |
Description |
service
|
string |
name of the service which should be a match to gRPC service definition name
|
methodName
|
string |
name of the method which is coming after rpc keyword
|
streaming
|
GrpcMethodStreamingType |
GrpcMethodStreamingType parameter which should correspond to
stream keyword in gRPC service request part
|
Returns
string
|
createServiceMethod()
|
|
Will return async function which will handle gRPC call
with Rx streams or as a direct call passthrough
|
createServiceMethod(methodHandler: Function, protoNativeHandler: any, streamType: GrpcMethodStreamingType): Function
Parameters
Returns
Function
|
createUnaryServiceMethod()
|
createUnaryServiceMethod(methodHandler: Function): Function
Parameters
| Option |
Type |
Description |
methodHandler
|
Function |
|
Returns
Function
|
createStreamServiceMethod()
|
createStreamServiceMethod(methodHandler: Function): Function
Parameters
| Option |
Type |
Description |
methodHandler
|
Function |
|
Returns
Function
|
createRequestStreamMethod()
|
createRequestStreamMethod(methodHandler: Function, isResponseStream: boolean)
Parameters
| Option |
Type |
Description |
methodHandler
|
Function |
|
isResponseStream
|
boolean |
|
|
createStreamCallMethod()
|
createStreamCallMethod(methodHandler: Function, isResponseStream: boolean)
Parameters
| Option |
Type |
Description |
methodHandler
|
Function |
|
isResponseStream
|
boolean |
|
|
close()
|
close()
Parameters
There are no parameters.
|
deserialize()
|
deserialize(obj: any): any
Parameters
| Option |
Type |
Description |
obj
|
any |
|
Returns
any
|
addHandler()
|
addHandler(pattern: unknown, callback: MessageHandler<any, any, any>, isEventHandler: boolean = false)
Parameters
| Option |
Type |
Description |
pattern
|
unknown |
|
callback
|
MessageHandler |
|
isEventHandler
|
boolean |
Optional. Default is false.
|
|
createClient()
|
createClient(): Promise<any>
Parameters
There are no parameters.
Returns
Promise<any>
|
lookupPackage()
|
lookupPackage(root: any, packageName: string)
Parameters
| Option |
Type |
Description |
root
|
any |
|
packageName
|
string |
|
|
loadProto()
|
loadProto(): any
Parameters
There are no parameters.
Returns
any
|