UNPKG

5.19 kBTypeScriptView Raw
1import { ChannelCredentials } from './channel-credentials';
2import { ChannelOptions } from './channel-options';
3import { Metadata } from './metadata';
4import { CallConfig } from './resolver';
5import { ServerSurfaceCall } from './server-call';
6import { ConnectivityState } from './connectivity-state';
7import { ChannelRef } from './channelz';
8import { LoadBalancingCall } from './load-balancing-call';
9import { CallCredentials } from './call-credentials';
10import { Call, StatusObject } from './call-interface';
11import { Deadline } from './deadline';
12import { ResolvingCall } from './resolving-call';
13import { RetryingCall } from './retrying-call';
14import { BaseSubchannelWrapper, SubchannelInterface } from './subchannel-interface';
15interface NoneConfigResult {
16 type: 'NONE';
17}
18interface SuccessConfigResult {
19 type: 'SUCCESS';
20 config: CallConfig;
21}
22interface ErrorConfigResult {
23 type: 'ERROR';
24 error: StatusObject;
25}
26type GetConfigResult = NoneConfigResult | SuccessConfigResult | ErrorConfigResult;
27declare class ChannelSubchannelWrapper extends BaseSubchannelWrapper implements SubchannelInterface {
28 private channel;
29 private refCount;
30 private subchannelStateListener;
31 constructor(childSubchannel: SubchannelInterface, channel: InternalChannel);
32 ref(): void;
33 unref(): void;
34}
35export declare class InternalChannel {
36 private readonly credentials;
37 private readonly options;
38 private readonly resolvingLoadBalancer;
39 private readonly subchannelPool;
40 private connectivityState;
41 private currentPicker;
42 /**
43 * Calls queued up to get a call config. Should only be populated before the
44 * first time the resolver returns a result, which includes the ConfigSelector.
45 */
46 private configSelectionQueue;
47 private pickQueue;
48 private connectivityStateWatchers;
49 private readonly defaultAuthority;
50 private readonly filterStackFactory;
51 private readonly target;
52 /**
53 * This timer does not do anything on its own. Its purpose is to hold the
54 * event loop open while there are any pending calls for the channel that
55 * have not yet been assigned to specific subchannels. In other words,
56 * the invariant is that callRefTimer is reffed if and only if pickQueue
57 * is non-empty.
58 */
59 private readonly callRefTimer;
60 private configSelector;
61 /**
62 * This is the error from the name resolver if it failed most recently. It
63 * is only used to end calls that start while there is no config selector
64 * and the name resolver is in backoff, so it should be nulled if
65 * configSelector becomes set or the channel state becomes anything other
66 * than TRANSIENT_FAILURE.
67 */
68 private currentResolutionError;
69 private readonly retryBufferTracker;
70 private keepaliveTime;
71 private readonly wrappedSubchannels;
72 private callCount;
73 private idleTimer;
74 private readonly idleTimeoutMs;
75 private readonly channelzEnabled;
76 private readonly originalTarget;
77 private readonly channelzRef;
78 private readonly channelzTrace;
79 private readonly callTracker;
80 private readonly childrenTracker;
81 constructor(target: string, credentials: ChannelCredentials, options: ChannelOptions);
82 private getChannelzInfo;
83 private trace;
84 private callRefTimerRef;
85 private callRefTimerUnref;
86 private removeConnectivityStateWatcher;
87 private updateState;
88 throttleKeepalive(newKeepaliveTime: number): void;
89 removeWrappedSubchannel(wrappedSubchannel: ChannelSubchannelWrapper): void;
90 doPick(metadata: Metadata, extraPickInfo: {
91 [key: string]: string;
92 }): import("./picker").PickResult;
93 queueCallForPick(call: LoadBalancingCall): void;
94 getConfig(method: string, metadata: Metadata): GetConfigResult;
95 queueCallForConfig(call: ResolvingCall): void;
96 private enterIdle;
97 private maybeStartIdleTimer;
98 private onCallStart;
99 private onCallEnd;
100 createLoadBalancingCall(callConfig: CallConfig, method: string, host: string, credentials: CallCredentials, deadline: Deadline): LoadBalancingCall;
101 createRetryingCall(callConfig: CallConfig, method: string, host: string, credentials: CallCredentials, deadline: Deadline): RetryingCall;
102 createInnerCall(callConfig: CallConfig, method: string, host: string, credentials: CallCredentials, deadline: Deadline): Call;
103 createResolvingCall(method: string, deadline: Deadline, host: string | null | undefined, parentCall: ServerSurfaceCall | null, propagateFlags: number | null | undefined): ResolvingCall;
104 close(): void;
105 getTarget(): string;
106 getConnectivityState(tryToConnect: boolean): ConnectivityState;
107 watchConnectivityState(currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void): void;
108 /**
109 * Get the channelz reference object for this channel. The returned value is
110 * garbage if channelz is disabled for this channel.
111 * @returns
112 */
113 getChannelzRef(): ChannelRef;
114 createCall(method: string, deadline: Deadline, host: string | null | undefined, parentCall: ServerSurfaceCall | null, propagateFlags: number | null | undefined): Call;
115}
116export {};