1 |
|
2 | import * as http2 from 'http2';
|
3 | import { StatusObject } from './call-interface';
|
4 | import { ChannelCredentials } from './channel-credentials';
|
5 | import { ChannelOptions } from './channel-options';
|
6 | import { SocketRef } from './channelz';
|
7 | import { SubchannelAddress } from './subchannel-address';
|
8 | import { GrpcUri } from './uri-parser';
|
9 | import { Http2SubchannelCall, SubchannelCall, SubchannelCallInterceptingListener } from './subchannel-call';
|
10 | import { Metadata } from './metadata';
|
11 | export interface CallEventTracker {
|
12 | addMessageSent(): void;
|
13 | addMessageReceived(): void;
|
14 | onCallEnd(status: StatusObject): void;
|
15 | onStreamEnd(success: boolean): void;
|
16 | }
|
17 | export interface TransportDisconnectListener {
|
18 | (tooManyPings: boolean): void;
|
19 | }
|
20 | export interface Transport {
|
21 | getChannelzRef(): SocketRef;
|
22 | getPeerName(): string;
|
23 | createCall(metadata: Metadata, host: string, method: string, listener: SubchannelCallInterceptingListener, subchannelCallStatsTracker: Partial<CallEventTracker>): SubchannelCall;
|
24 | addDisconnectListener(listener: TransportDisconnectListener): void;
|
25 | shutdown(): void;
|
26 | }
|
27 | declare class Http2Transport implements Transport {
|
28 | private session;
|
29 | |
30 |
|
31 |
|
32 |
|
33 | private remoteName;
|
34 | |
35 |
|
36 |
|
37 | private keepaliveTimeMs;
|
38 | |
39 |
|
40 |
|
41 | private keepaliveTimeoutMs;
|
42 | |
43 |
|
44 |
|
45 | private keepaliveTimerId;
|
46 | |
47 |
|
48 |
|
49 |
|
50 | private pendingSendKeepalivePing;
|
51 | |
52 |
|
53 |
|
54 | private keepaliveTimeoutId;
|
55 | |
56 |
|
57 |
|
58 | private keepaliveWithoutCalls;
|
59 | private userAgent;
|
60 | private activeCalls;
|
61 | private subchannelAddressString;
|
62 | private disconnectListeners;
|
63 | private disconnectHandled;
|
64 | private channelzRef;
|
65 | private readonly channelzEnabled;
|
66 | private streamTracker;
|
67 | private keepalivesSent;
|
68 | private messagesSent;
|
69 | private messagesReceived;
|
70 | private lastMessageSentTimestamp;
|
71 | private lastMessageReceivedTimestamp;
|
72 | constructor(session: http2.ClientHttp2Session, subchannelAddress: SubchannelAddress, options: ChannelOptions,
|
73 | |
74 |
|
75 |
|
76 |
|
77 | remoteName: string | null);
|
78 | private getChannelzInfo;
|
79 | private trace;
|
80 | private keepaliveTrace;
|
81 | private flowControlTrace;
|
82 | private internalsTrace;
|
83 | /**
|
84 | * Indicate to the owner of this object that this transport should no longer
|
85 | * be used. That happens if the connection drops, or if the server sends a
|
86 | * GOAWAY.
|
87 | * @param tooManyPings If true, this was triggered by a GOAWAY with data
|
88 | * indicating that the session was closed becaues the client sent too many
|
89 | * pings.
|
90 | * @returns
|
91 | */
|
92 | private reportDisconnectToOwner;
|
93 | /**
|
94 | * Handle connection drops, but not GOAWAYs.
|
95 | */
|
96 | private handleDisconnect;
|
97 | addDisconnectListener(listener: TransportDisconnectListener): void;
|
98 | private clearKeepaliveTimer;
|
99 | private clearKeepaliveTimeout;
|
100 | private canSendPing;
|
101 | private maybeSendPing;
|
102 | /**
|
103 | * Starts the keepalive ping timer if appropriate. If the timer already ran
|
104 | * out while there were no active requests, instead send a ping immediately.
|
105 | * If the ping timer is already running or a ping is currently in flight,
|
106 | * instead do nothing and wait for them to resolve.
|
107 | */
|
108 | private maybeStartKeepalivePingTimer;
|
109 | private stopKeepalivePings;
|
110 | private removeActiveCall;
|
111 | private addActiveCall;
|
112 | createCall(metadata: Metadata, host: string, method: string, listener: SubchannelCallInterceptingListener, subchannelCallStatsTracker: Partial<CallEventTracker>): Http2SubchannelCall;
|
113 | getChannelzRef(): SocketRef;
|
114 | getPeerName(): string;
|
115 | shutdown(): void;
|
116 | }
|
117 | export interface SubchannelConnector {
|
118 | connect(address: SubchannelAddress, credentials: ChannelCredentials, options: ChannelOptions): Promise<Transport>;
|
119 | shutdown(): void;
|
120 | }
|
121 | export declare class Http2SubchannelConnector implements SubchannelConnector {
|
122 | private channelTarget;
|
123 | private session;
|
124 | private isShutdown;
|
125 | constructor(channelTarget: GrpcUri);
|
126 | private trace;
|
127 | private createSession;
|
128 | connect(address: SubchannelAddress, credentials: ChannelCredentials, options: ChannelOptions): Promise<Http2Transport>;
|
129 | shutdown(): void;
|
130 | }
|
131 | export {};
|