1 |
|
2 | import { Deserialize, Serialize, ServiceDefinition } from './make-client';
|
3 | import { HandleCall } from './server-call';
|
4 | import { ServerCredentials } from './server-credentials';
|
5 | import { ChannelOptions } from './channel-options';
|
6 | import { ServerRef } from './channelz';
|
7 | import { ServerInterceptor } from './server-interceptors';
|
8 | import { Duplex } from 'stream';
|
9 | export type UntypedHandleCall = HandleCall<any, any>;
|
10 | export interface UntypedServiceImplementation {
|
11 | [name: string]: UntypedHandleCall;
|
12 | }
|
13 | export interface ServerOptions extends ChannelOptions {
|
14 | interceptors?: ServerInterceptor[];
|
15 | }
|
16 | export interface ConnectionInjector {
|
17 | injectConnection(connection: Duplex): void;
|
18 | drain(graceTimeMs: number): void;
|
19 | destroy(): void;
|
20 | }
|
21 | export declare class Server {
|
22 | private boundPorts;
|
23 | private http2Servers;
|
24 | private sessionIdleTimeouts;
|
25 | private handlers;
|
26 | private sessions;
|
27 | |
28 |
|
29 |
|
30 |
|
31 | private started;
|
32 | private shutdown;
|
33 | private options;
|
34 | private serverAddressString;
|
35 | private readonly channelzEnabled;
|
36 | private channelzRef;
|
37 | private channelzTrace;
|
38 | private callTracker;
|
39 | private listenerChildrenTracker;
|
40 | private sessionChildrenTracker;
|
41 | private readonly maxConnectionAgeMs;
|
42 | private readonly maxConnectionAgeGraceMs;
|
43 | private readonly keepaliveTimeMs;
|
44 | private readonly keepaliveTimeoutMs;
|
45 | private readonly sessionIdleTimeout;
|
46 | private readonly interceptors;
|
47 | |
48 |
|
49 |
|
50 |
|
51 | private commonServerOptions;
|
52 | constructor(options?: ServerOptions);
|
53 | private getChannelzInfo;
|
54 | private getChannelzSessionInfo;
|
55 | private trace;
|
56 | private keepaliveTrace;
|
57 | addProtoService(): never;
|
58 | addService(service: ServiceDefinition, implementation: UntypedServiceImplementation): void;
|
59 | removeService(service: ServiceDefinition): void;
|
60 | bind(port: string, creds: ServerCredentials): never;
|
61 | private registerListenerToChannelz;
|
62 | private createHttp2Server;
|
63 | private bindOneAddress;
|
64 | private bindManyPorts;
|
65 | private bindAddressList;
|
66 | private resolvePort;
|
67 | private bindPort;
|
68 | private normalizePort;
|
69 | bindAsync(port: string, creds: ServerCredentials, callback: (error: Error | null, port: number) => void): void;
|
70 | private registerInjectorToChannelz;
|
71 | createConnectionInjector(credentials: ServerCredentials): ConnectionInjector;
|
72 | private closeServer;
|
73 | private closeSession;
|
74 | private completeUnbind;
|
75 | /**
|
76 | * Unbind a previously bound port, or cancel an in-progress bindAsync
|
77 | * operation. If port 0 was bound, only the actual bound port can be
|
78 | * unbound. For example, if bindAsync was called with "localhost:0" and the
|
79 | * bound port result was 54321, it can be unbound as "localhost:54321".
|
80 | * @param port
|
81 | */
|
82 | unbind(port: string): void;
|
83 | /**
|
84 | * Gracefully close all connections associated with a previously bound port.
|
85 | * After the grace time, forcefully close all remaining open connections.
|
86 | *
|
87 | * If port 0 was bound, only the actual bound port can be
|
88 | * drained. For example, if bindAsync was called with "localhost:0" and the
|
89 | * bound port result was 54321, it can be drained as "localhost:54321".
|
90 | * @param port
|
91 | * @param graceTimeMs
|
92 | * @returns
|
93 | */
|
94 | drain(port: string, graceTimeMs: number): void;
|
95 | forceShutdown(): void;
|
96 | register<RequestType, ResponseType>(name: string, handler: HandleCall<RequestType, ResponseType>, serialize: Serialize<ResponseType>, deserialize: Deserialize<RequestType>, type: string): boolean;
|
97 | unregister(name: string): boolean;
|
98 | /**
|
99 | * @deprecated No longer needed as of version 1.10.x
|
100 | */
|
101 | start(): void;
|
102 | tryShutdown(callback: (error?: Error) => void): void;
|
103 | addHttp2Port(): never;
|
104 | /**
|
105 | * Get the channelz reference object for this server. The returned value is
|
106 | * garbage if channelz is disabled for this server.
|
107 | * @returns
|
108 | */
|
109 | getChannelzRef(): ServerRef;
|
110 | private _verifyContentType;
|
111 | private _retrieveHandler;
|
112 | private _respondWithError;
|
113 | private _channelzHandler;
|
114 | private _streamHandler;
|
115 | private _runHandlerForCall;
|
116 | private _setupHandlers;
|
117 | private _sessionHandler;
|
118 | private _channelzSessionHandler;
|
119 | private enableIdleTimeout;
|
120 | private onIdleTimeout;
|
121 | private onStreamOpened;
|
122 | private onStreamClose;
|
123 | }
|