UNPKG

2.83 kBTypeScriptView Raw
1import { LoadBalancer, ChannelControlHelper, LoadBalancingConfig } from './load-balancer';
2import { SubchannelAddress } from './subchannel-address';
3export declare class PickFirstLoadBalancingConfig implements LoadBalancingConfig {
4 getLoadBalancerName(): string;
5 constructor();
6 toJsonObject(): object;
7 static createFromJson(obj: any): PickFirstLoadBalancingConfig;
8}
9export declare class PickFirstLoadBalancer implements LoadBalancer {
10 private readonly channelControlHelper;
11 /**
12 * The list of backend addresses most recently passed to `updateAddressList`.
13 */
14 private latestAddressList;
15 /**
16 * The list of subchannels this load balancer is currently attempting to
17 * connect to.
18 */
19 private subchannels;
20 /**
21 * The current connectivity state of the load balancer.
22 */
23 private currentState;
24 /**
25 * The index within the `subchannels` array of the subchannel with the most
26 * recently started connection attempt.
27 */
28 private currentSubchannelIndex;
29 private subchannelStateCounts;
30 /**
31 * The currently picked subchannel used for making calls. Populated if
32 * and only if the load balancer's current state is READY. In that case,
33 * the subchannel's current state is also READY.
34 */
35 private currentPick;
36 /**
37 * Listener callback attached to each subchannel in the `subchannels` list
38 * while establishing a connection.
39 */
40 private subchannelStateListener;
41 /**
42 * Listener callback attached to the current picked subchannel.
43 */
44 private pickedSubchannelStateListener;
45 /**
46 * Timer reference for the timer tracking when to start
47 */
48 private connectionDelayTimeout;
49 private triedAllSubchannels;
50 /**
51 * Load balancer that attempts to connect to each backend in the address list
52 * in order, and picks the first one that connects, using it for every
53 * request.
54 * @param channelControlHelper `ChannelControlHelper` instance provided by
55 * this load balancer's owner.
56 */
57 constructor(channelControlHelper: ChannelControlHelper);
58 private startNextSubchannelConnecting;
59 /**
60 * Have a single subchannel in the `subchannels` list start connecting.
61 * @param subchannelIndex The index into the `subchannels` list.
62 */
63 private startConnecting;
64 private pickSubchannel;
65 private updateState;
66 private resetSubchannelList;
67 /**
68 * Start connecting to the address list most recently passed to
69 * `updateAddressList`.
70 */
71 private connectToAddressList;
72 updateAddressList(addressList: SubchannelAddress[], lbConfig: LoadBalancingConfig): void;
73 exitIdle(): void;
74 resetBackoff(): void;
75 destroy(): void;
76 getTypeName(): string;
77}
78export declare function setup(): void;