UNPKG

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