UNPKG

1.84 kBTypeScriptView Raw
1import { SubchannelRef } from "./channelz";
2import { ConnectivityState } from "./connectivity-state";
3import { Subchannel } from "./subchannel";
4export type ConnectivityStateListener = (subchannel: SubchannelInterface, previousState: ConnectivityState, newState: ConnectivityState, keepaliveTime: number) => 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 throttleKeepalive(newKeepaliveTime: number): void;
21 ref(): void;
22 unref(): void;
23 getChannelzRef(): SubchannelRef;
24 /**
25 * If this is a wrapper, return the wrapped subchannel, otherwise return this
26 */
27 getRealSubchannel(): Subchannel;
28}
29export declare abstract class BaseSubchannelWrapper implements SubchannelInterface {
30 protected child: SubchannelInterface;
31 constructor(child: SubchannelInterface);
32 getConnectivityState(): ConnectivityState;
33 addConnectivityStateListener(listener: ConnectivityStateListener): void;
34 removeConnectivityStateListener(listener: ConnectivityStateListener): void;
35 startConnecting(): void;
36 getAddress(): string;
37 throttleKeepalive(newKeepaliveTime: number): void;
38 ref(): void;
39 unref(): void;
40 getChannelzRef(): SubchannelRef;
41 getRealSubchannel(): Subchannel;
42}