1 | import { Observable } from 'rxjs';
|
2 | import { GrpcMethodStreamingType } from '../decorators';
|
3 | import { Transport } from '../enums';
|
4 | import { CustomTransportStrategy, MessageHandler } from '../interfaces';
|
5 | import { GrpcOptions } from '../interfaces/microservice-configuration.interface';
|
6 | import { Server } from './server';
|
7 | interface GrpcCall<TRequest = any, TMetadata = any> {
|
8 | request: TRequest;
|
9 | metadata: TMetadata;
|
10 | sendMetadata: Function;
|
11 | end: Function;
|
12 | write: Function;
|
13 | on: Function;
|
14 | off: Function;
|
15 | emit: Function;
|
16 | }
|
17 | export declare class ServerGrpc extends Server implements CustomTransportStrategy {
|
18 | private readonly options;
|
19 | readonly transportId = Transport.GRPC;
|
20 | private readonly url;
|
21 | private grpcClient;
|
22 | constructor(options: GrpcOptions['options']);
|
23 | listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>;
|
24 | start(callback?: () => void): Promise<void>;
|
25 | bindEvents(): Promise<void>;
|
26 | /**
|
27 | * Will return all of the services along with their fully namespaced
|
28 | * names as an array of objects.
|
29 | * This method initiates recursive scan of grpcPkg object
|
30 | */
|
31 | getServiceNames(grpcPkg: any): {
|
32 | name: string;
|
33 | service: any;
|
34 | }[];
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | createService(grpcService: any, name: string): Promise<{}>;
|
43 | |
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | createPattern(service: string, methodName: string, streaming: GrpcMethodStreamingType): string;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | createServiceMethod(methodHandler: Function, protoNativeHandler: any, streamType: GrpcMethodStreamingType): Function;
|
60 | createUnaryServiceMethod(methodHandler: Function): Function;
|
61 | createStreamServiceMethod(methodHandler: Function): Function;
|
62 | |
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | writeObservableToGrpc<T>(source: Observable<T>, call: GrpcCall<T>): Promise<void>;
|
73 | createRequestStreamMethod(methodHandler: Function, isResponseStream: boolean): (call: GrpcCall, callback: (err: unknown, value: unknown) => void) => Promise<void>;
|
74 | createStreamCallMethod(methodHandler: Function, isResponseStream: boolean): (call: GrpcCall, callback: (err: unknown, value: unknown) => void) => Promise<void>;
|
75 | close(): Promise<void>;
|
76 | deserialize(obj: any): any;
|
77 | addHandler(pattern: unknown, callback: MessageHandler, isEventHandler?: boolean): void;
|
78 | createClient(): Promise<any>;
|
79 | lookupPackage(root: any, packageName: string): any;
|
80 | loadProto(): any;
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | private collectDeepServices;
|
95 | private parseDeepServiceName;
|
96 | private createServices;
|
97 | }
|
98 | export {};
|