1 | import { ChannelOptions } from './channel-options';
|
2 | import { SubchannelAddress } from './subchannel-address';
|
3 | import { ConnectivityState } from './connectivity-state';
|
4 | import { Picker } from './picker';
|
5 | import { ChannelRef, SubchannelRef } from './channelz';
|
6 | import { SubchannelInterface } from './subchannel-interface';
|
7 | /**
|
8 | * A collection of functions associated with a channel that a load balancer
|
9 | * can call as necessary.
|
10 | */
|
11 | export interface ChannelControlHelper {
|
12 | /**
|
13 | * Returns a subchannel connected to the specified address.
|
14 | * @param subchannelAddress The address to connect to
|
15 | * @param subchannelArgs Extra channel arguments specified by the load balancer
|
16 | */
|
17 | createSubchannel(subchannelAddress: SubchannelAddress, subchannelArgs: ChannelOptions): SubchannelInterface;
|
18 | /**
|
19 | * Passes a new subchannel picker up to the channel. This is called if either
|
20 | * the connectivity state changes or if a different picker is needed for any
|
21 | * other reason.
|
22 | * @param connectivityState New connectivity state
|
23 | * @param picker New picker
|
24 | */
|
25 | updateState(connectivityState: ConnectivityState, picker: Picker): void;
|
26 | /**
|
27 | * Request new data from the resolver.
|
28 | */
|
29 | requestReresolution(): void;
|
30 | addChannelzChild(child: ChannelRef | SubchannelRef): void;
|
31 | removeChannelzChild(child: ChannelRef | SubchannelRef): void;
|
32 | }
|
33 | /**
|
34 | * Create a child ChannelControlHelper that overrides some methods of the
|
35 | * parent while letting others pass through to the parent unmodified. This
|
36 | * allows other code to create these children without needing to know about
|
37 | * all of the methods to be passed through.
|
38 | * @param parent
|
39 | * @param overrides
|
40 | */
|
41 | export declare function createChildChannelControlHelper(parent: ChannelControlHelper, overrides: Partial<ChannelControlHelper>): ChannelControlHelper;
|
42 | /**
|
43 | * Tracks one or more connected subchannels and determines which subchannel
|
44 | * each request should use.
|
45 | */
|
46 | export interface LoadBalancer {
|
47 | /**
|
48 | * Gives the load balancer a new list of addresses to start connecting to.
|
49 | * The load balancer will start establishing connections with the new list,
|
50 | * but will continue using any existing connections until the new connections
|
51 | * are established
|
52 | * @param addressList The new list of addresses to connect to
|
53 | * @param lbConfig The load balancing config object from the service config,
|
54 | * if one was provided
|
55 | */
|
56 | updateAddressList(addressList: SubchannelAddress[], lbConfig: LoadBalancingConfig, attributes: {
|
57 | [key: string]: unknown;
|
58 | }): void;
|
59 | /**
|
60 | * If the load balancer is currently in the IDLE state, start connecting.
|
61 | */
|
62 | exitIdle(): void;
|
63 | /**
|
64 | * If the load balancer is currently in the CONNECTING or TRANSIENT_FAILURE
|
65 | * state, reset the current connection backoff timeout to its base value and
|
66 | * transition to CONNECTING if in TRANSIENT_FAILURE.
|
67 | */
|
68 | resetBackoff(): void;
|
69 | /**
|
70 | * The load balancer unrefs all of its subchannels and stops calling methods
|
71 | * of its channel control helper.
|
72 | */
|
73 | destroy(): void;
|
74 | /**
|
75 | * Get the type name for this load balancer type. Must be constant across an
|
76 | * entire load balancer implementation class and must match the name that the
|
77 | * balancer implementation class was registered with.
|
78 | */
|
79 | getTypeName(): string;
|
80 | }
|
81 | export interface LoadBalancerConstructor {
|
82 | new (channelControlHelper: ChannelControlHelper): LoadBalancer;
|
83 | }
|
84 | export interface LoadBalancingConfig {
|
85 | getLoadBalancerName(): string;
|
86 | toJsonObject(): object;
|
87 | }
|
88 | export interface LoadBalancingConfigConstructor {
|
89 | new (...args: any): LoadBalancingConfig;
|
90 | createFromJson(obj: any): LoadBalancingConfig;
|
91 | }
|
92 | export declare function registerLoadBalancerType(typeName: string, loadBalancerType: LoadBalancerConstructor, loadBalancingConfigType: LoadBalancingConfigConstructor): void;
|
93 | export declare function registerDefaultLoadBalancerType(typeName: string): void;
|
94 | export declare function createLoadBalancer(config: LoadBalancingConfig, channelControlHelper: ChannelControlHelper): LoadBalancer | null;
|
95 | export declare function isLoadBalancerNameRegistered(typeName: string): boolean;
|
96 | export declare function getFirstUsableConfig(configs: LoadBalancingConfig[], fallbackTodefault?: true): LoadBalancingConfig;
|
97 | export declare function validateLoadBalancingConfig(obj: any): LoadBalancingConfig;
|