UNPKG

1.72 kBTypeScriptView Raw
1import { SubchannelRef } from "./channelz";
2import { ConnectivityState } from "./connectivity-state";
3import { Subchannel } from "./subchannel";
4export declare type ConnectivityStateListener = (subchannel: SubchannelInterface, previousState: ConnectivityState, newState: ConnectivityState) => void;
5/**
6 * This is an interface for load balancing policies to use to interact with
7 * subchannels. This allows load balancing policies to wrap and unwrap
8 * subchannels.
9 *
10 * Any load balancing policy that wraps subchannels must unwrap the subchannel
11 * in the picker, so that other load balancing policies consistently have
12 * access to their own wrapper objects.
13 */
14export interface SubchannelInterface {
15 getConnectivityState(): ConnectivityState;
16 addConnectivityStateListener(listener: ConnectivityStateListener): void;
17 removeConnectivityStateListener(listener: ConnectivityStateListener): void;
18 startConnecting(): void;
19 getAddress(): string;
20 ref(): void;
21 unref(): void;
22 getChannelzRef(): SubchannelRef;
23 /**
24 * If this is a wrapper, return the wrapped subchannel, otherwise return this
25 */
26 getRealSubchannel(): Subchannel;
27}
28export declare abstract class BaseSubchannelWrapper implements SubchannelInterface {
29 protected child: SubchannelInterface;
30 constructor(child: SubchannelInterface);
31 getConnectivityState(): ConnectivityState;
32 addConnectivityStateListener(listener: ConnectivityStateListener): void;
33 removeConnectivityStateListener(listener: ConnectivityStateListener): void;
34 startConnecting(): void;
35 getAddress(): string;
36 ref(): void;
37 unref(): void;
38 getChannelzRef(): SubchannelRef;
39 getRealSubchannel(): Subchannel;
40}