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 | private keepaliveTimeMs;
|
33 | |
34 |
|
35 |
|
36 | private keepaliveTimeoutMs;
|
37 | |
38 |
|
39 |
|
40 | private keepaliveIntervalId;
|
41 | |
42 |
|
43 |
|
44 | private keepaliveTimeoutId;
|
45 | |
46 |
|
47 |
|
48 | private keepaliveWithoutCalls;
|
49 | private userAgent;
|
50 | private activeCalls;
|
51 | private subchannelAddressString;
|
52 | private disconnectListeners;
|
53 | private disconnectHandled;
|
54 | private channelzRef;
|
55 | private readonly channelzEnabled;
|
56 | |
57 |
|
58 |
|
59 |
|
60 | private remoteName;
|
61 | private streamTracker;
|
62 | private keepalivesSent;
|
63 | private messagesSent;
|
64 | private messagesReceived;
|
65 | private lastMessageSentTimestamp;
|
66 | private lastMessageReceivedTimestamp;
|
67 | constructor(session: http2.ClientHttp2Session, subchannelAddress: SubchannelAddress, options: ChannelOptions);
|
68 | private getChannelzInfo;
|
69 | private trace;
|
70 | private keepaliveTrace;
|
71 | private flowControlTrace;
|
72 | private internalsTrace;
|
73 | /**
|
74 | * Indicate to the owner of this object that this transport should no longer
|
75 | * be used. That happens if the connection drops, or if the server sends a
|
76 | * GOAWAY.
|
77 | * @param tooManyPings If true, this was triggered by a GOAWAY with data
|
78 | * indicating that the session was closed becaues the client sent too many
|
79 | * pings.
|
80 | * @returns
|
81 | */
|
82 | private reportDisconnectToOwner;
|
83 | /**
|
84 | * Handle connection drops, but not GOAWAYs.
|
85 | */
|
86 | private handleDisconnect;
|
87 | addDisconnectListener(listener: TransportDisconnectListener): void;
|
88 | private clearKeepaliveTimeout;
|
89 | private sendPing;
|
90 | private startKeepalivePings;
|
91 | /**
|
92 | * Stop keepalive pings when terminating a connection. This discards the
|
93 | * outstanding ping timeout, so it should not be called if the same
|
94 | * connection will still be used.
|
95 | */
|
96 | private stopKeepalivePings;
|
97 | private removeActiveCall;
|
98 | private addActiveCall;
|
99 | createCall(metadata: Metadata, host: string, method: string, listener: SubchannelCallInterceptingListener, subchannelCallStatsTracker: Partial<CallEventTracker>): Http2SubchannelCall;
|
100 | getChannelzRef(): SocketRef;
|
101 | getPeerName(): string;
|
102 | shutdown(): void;
|
103 | }
|
104 | export interface SubchannelConnector {
|
105 | connect(address: SubchannelAddress, credentials: ChannelCredentials, options: ChannelOptions): Promise<Transport>;
|
106 | shutdown(): void;
|
107 | }
|
108 | export declare class Http2SubchannelConnector implements SubchannelConnector {
|
109 | private channelTarget;
|
110 | private session;
|
111 | private isShutdown;
|
112 | constructor(channelTarget: GrpcUri);
|
113 | private trace;
|
114 | private createSession;
|
115 | connect(address: SubchannelAddress, credentials: ChannelCredentials, options: ChannelOptions): Promise<Http2Transport>;
|
116 | shutdown(): void;
|
117 | }
|
118 | export {};
|