1 | import { ChannelCredentials } from './channel-credentials';
|
2 | import { Metadata } from './metadata';
|
3 | import { Http2CallStream } from './call-stream';
|
4 | import { ChannelOptions } from './channel-options';
|
5 | import { ConnectivityState } from './connectivity-state';
|
6 | import { GrpcUri } from './uri-parser';
|
7 | import { Filter } from './filter';
|
8 | import { SubchannelAddress } from './subchannel-address';
|
9 | import { SubchannelRef } from './channelz';
|
10 | import { ConnectivityStateListener } from './subchannel-interface';
|
11 | export interface SubchannelCallStatsTracker {
|
12 | addMessageSent(): void;
|
13 | addMessageReceived(): void;
|
14 | }
|
15 | export declare class Subchannel {
|
16 | private channelTarget;
|
17 | private subchannelAddress;
|
18 | private options;
|
19 | private credentials;
|
20 | |
21 |
|
22 |
|
23 |
|
24 | private connectivityState;
|
25 | |
26 |
|
27 |
|
28 | private session;
|
29 | |
30 |
|
31 |
|
32 |
|
33 | private continueConnecting;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | private stateListeners;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | private disconnectListeners;
|
46 | private backoffTimeout;
|
47 | |
48 |
|
49 |
|
50 | private userAgent;
|
51 | |
52 |
|
53 |
|
54 | private keepaliveTimeMs;
|
55 | |
56 |
|
57 |
|
58 | private keepaliveTimeoutMs;
|
59 | |
60 |
|
61 |
|
62 | private keepaliveIntervalId;
|
63 | |
64 |
|
65 |
|
66 | private keepaliveTimeoutId;
|
67 | |
68 |
|
69 |
|
70 | private keepaliveWithoutCalls;
|
71 | |
72 |
|
73 |
|
74 | private callRefcount;
|
75 | |
76 |
|
77 |
|
78 | private refcount;
|
79 | |
80 |
|
81 |
|
82 | private subchannelAddressString;
|
83 | private readonly channelzEnabled;
|
84 | private channelzRef;
|
85 | private channelzTrace;
|
86 | private callTracker;
|
87 | private childrenTracker;
|
88 | private channelzSocketRef;
|
89 | |
90 |
|
91 |
|
92 |
|
93 | private remoteName;
|
94 | private streamTracker;
|
95 | private keepalivesSent;
|
96 | private messagesSent;
|
97 | private messagesReceived;
|
98 | private lastMessageSentTimestamp;
|
99 | private lastMessageReceivedTimestamp;
|
100 | |
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | constructor(channelTarget: GrpcUri, subchannelAddress: SubchannelAddress, options: ChannelOptions, credentials: ChannelCredentials);
|
111 | private getChannelzInfo;
|
112 | private getChannelzSocketInfo;
|
113 | private resetChannelzSocketInfo;
|
114 | private trace;
|
115 | private refTrace;
|
116 | private flowControlTrace;
|
117 | private internalsTrace;
|
118 | private keepaliveTrace;
|
119 | private handleBackoffTimer;
|
120 | /**
|
121 | * Start a backoff timer with the current nextBackoff timeout
|
122 | */
|
123 | private startBackoff;
|
124 | private stopBackoff;
|
125 | private sendPing;
|
126 | private startKeepalivePings;
|
127 | /**
|
128 | * Stop keepalive pings when terminating a connection. This discards the
|
129 | * outstanding ping timeout, so it should not be called if the same
|
130 | * connection will still be used.
|
131 | */
|
132 | private stopKeepalivePings;
|
133 | private createSession;
|
134 | private startConnectingInternal;
|
135 | private handleDisconnect;
|
136 | /**
|
137 | * Initiate a state transition from any element of oldStates to the new
|
138 | * state. If the current connectivityState is not in oldStates, do nothing.
|
139 | * @param oldStates The set of states to transition from
|
140 | * @param newState The state to transition to
|
141 | * @returns True if the state changed, false otherwise
|
142 | */
|
143 | private transitionToState;
|
144 | /**
|
145 | * Check if the subchannel associated with zero calls and with zero channels.
|
146 | * If so, shut it down.
|
147 | */
|
148 | private checkBothRefcounts;
|
149 | callRef(): void;
|
150 | callUnref(): void;
|
151 | ref(): void;
|
152 | unref(): void;
|
153 | unrefIfOneRef(): boolean;
|
154 | /**
|
155 | * Start a stream on the current session with the given `metadata` as headers
|
156 | * and then attach it to the `callStream`. Must only be called if the
|
157 | * subchannel's current connectivity state is READY.
|
158 | * @param metadata
|
159 | * @param callStream
|
160 | */
|
161 | startCallStream(metadata: Metadata, callStream: Http2CallStream, extraFilters: Filter[]): void;
|
162 | /**
|
163 | * If the subchannel is currently IDLE, start connecting and switch to the
|
164 | * CONNECTING state. If the subchannel is current in TRANSIENT_FAILURE,
|
165 | * the next time it would transition to IDLE, start connecting again instead.
|
166 | * Otherwise, do nothing.
|
167 | */
|
168 | startConnecting(): void;
|
169 | /**
|
170 | * Get the subchannel's current connectivity state.
|
171 | */
|
172 | getConnectivityState(): ConnectivityState;
|
173 | /**
|
174 | * Add a listener function to be called whenever the subchannel's
|
175 | * connectivity state changes.
|
176 | * @param listener
|
177 | */
|
178 | addConnectivityStateListener(listener: ConnectivityStateListener): void;
|
179 | /**
|
180 | * Remove a listener previously added with `addConnectivityStateListener`
|
181 | * @param listener A reference to a function previously passed to
|
182 | * `addConnectivityStateListener`
|
183 | */
|
184 | removeConnectivityStateListener(listener: ConnectivityStateListener): void;
|
185 | addDisconnectListener(listener: () => void): void;
|
186 | removeDisconnectListener(listener: () => void): void;
|
187 | /**
|
188 | * Reset the backoff timeout, and immediately start connecting if in backoff.
|
189 | */
|
190 | resetBackoff(): void;
|
191 | getAddress(): string;
|
192 | getChannelzRef(): SubchannelRef;
|
193 | getRealSubchannel(): this;
|
194 | }
|