Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ServerGrpc

Hierarchy

Implements

Index

Constructors

constructor

  • new ServerGrpc(options: GrpcOptions["options"]): ServerGrpc

Properties

Protected deserializer

deserializer: ConsumerDeserializer

Private grpcClient

grpcClient: any

Protected Readonly logger

logger: Logger = new Logger(Server.name)

Protected Readonly messageHandlers

messageHandlers: Map<string, MessageHandler<any, any, any>> = new Map<string, MessageHandler>()

Private Readonly options

options: GrpcOptions["options"]

Protected serializer

serializer: ConsumerSerializer

Readonly transportId

transportId: GRPC = Transport.GRPC

Private Readonly url

url: string

Methods

addHandler

  • addHandler(pattern: any, callback: MessageHandler, isEventHandler?: boolean): void

bindEvents

  • bindEvents(): Promise<void>

close

  • close(): void

Private collectDeepServices

  • collectDeepServices(name: string, grpcDefinition: any, accumulator: { name: string; service: any }[]): void
  • Recursively fetch all of the service methods available on loaded protobuf descriptor object, and collect those as an objects with dot-syntax full-path names.

    Example: for proto package Bundle.FirstService with service Events { rpc... will be resolved to object of (while loaded for Bundle package): { name: "FirstService.Events", service: {Object} }

    Parameters

    • name: string
    • grpcDefinition: any
    • accumulator: { name: string; service: any }[]

    Returns void

createClient

  • createClient(): any

createPattern

  • Will create a string of a JSON serialized format

    Parameters

    • 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

createRequestStreamMethod

  • createRequestStreamMethod(methodHandler: Function, isResponseStream: boolean): (Anonymous function)

createService

  • createService(grpcService: any, name: string): Promise<{}>
  • Will create service mapping from gRPC generated Object to handlers defined with @GrpcMethod or @GrpcStreamMethod annotations

    Parameters

    • grpcService: any
    • name: string

    Returns Promise<{}>

createServiceMethod

Private createServices

  • createServices(grpcPkg: any): Promise<void>

createStreamCallMethod

  • createStreamCallMethod(methodHandler: Function, isResponseStream: boolean): (Anonymous function)

createStreamServiceMethod

createUnaryServiceMethod

deserialize

  • deserialize(obj: any): any

getHandlerByPattern

getHandlers

getOptionsProp

  • getOptionsProp<T, K>(obj: T, prop: K, defaultValue?: T[K]): T[K]

Protected getRouteFromPattern

  • getRouteFromPattern(pattern: string): string

getServiceNames

  • getServiceNames(grpcPkg: any): { name: string; service: any }[]
  • 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

    Parameters

    • grpcPkg: any

    Returns { name: string; service: any }[]

Protected handleError

  • handleError(error: string): void

handleEvent

Protected initializeDeserializer

  • initializeDeserializer(options: ClientOptions["options"]): void

Protected initializeSerializer

  • initializeSerializer(options: ClientOptions["options"]): void

listen

  • listen(callback: () => void): Promise<void>

Protected loadPackage

  • loadPackage<T>(name: string, ctx: string, loader?: Function): T

loadProto

  • loadProto(): any

lookupPackage

  • lookupPackage(root: any, packageName: string): any

Protected normalizePattern

  • normalizePattern(pattern: MsPattern): string

Private parseDeepServiceName

  • parseDeepServiceName(name: string, key: string): string

send

  • send(stream$: Observable<any>, respond: (data: WritePacket) => void): Subscription

start

  • start(callback?: () => void): Promise<void>

transformToObservable

  • transformToObservable<T>(resultOrDeferred: any): Observable<T>

Generated using TypeDoc