internal-channel.d.ts 5.5 KB

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