1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { SubchannelRef } from "./channelz";
|
19 | import { ConnectivityState } from "./connectivity-state";
|
20 | import { Subchannel } from "./subchannel";
|
21 |
|
22 | export type ConnectivityStateListener = (
|
23 | subchannel: SubchannelInterface,
|
24 | previousState: ConnectivityState,
|
25 | newState: ConnectivityState,
|
26 | keepaliveTime: number
|
27 | ) => void;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | export interface SubchannelInterface {
|
39 | getConnectivityState(): ConnectivityState;
|
40 | addConnectivityStateListener(listener: ConnectivityStateListener): void;
|
41 | removeConnectivityStateListener(listener: ConnectivityStateListener): void;
|
42 | startConnecting(): void;
|
43 | getAddress(): string;
|
44 | throttleKeepalive(newKeepaliveTime: number): void;
|
45 | ref(): void;
|
46 | unref(): void;
|
47 | getChannelzRef(): SubchannelRef;
|
48 | |
49 |
|
50 |
|
51 | getRealSubchannel(): Subchannel;
|
52 | }
|
53 |
|
54 | export abstract class BaseSubchannelWrapper implements SubchannelInterface {
|
55 | constructor(protected child: SubchannelInterface) {}
|
56 |
|
57 | getConnectivityState(): ConnectivityState {
|
58 | return this.child.getConnectivityState();
|
59 | }
|
60 | addConnectivityStateListener(listener: ConnectivityStateListener): void {
|
61 | this.child.addConnectivityStateListener(listener);
|
62 | }
|
63 | removeConnectivityStateListener(listener: ConnectivityStateListener): void {
|
64 | this.child.removeConnectivityStateListener(listener);
|
65 | }
|
66 | startConnecting(): void {
|
67 | this.child.startConnecting();
|
68 | }
|
69 | getAddress(): string {
|
70 | return this.child.getAddress();
|
71 | }
|
72 | throttleKeepalive(newKeepaliveTime: number): void {
|
73 | this.child.throttleKeepalive(newKeepaliveTime);
|
74 | }
|
75 | ref(): void {
|
76 | this.child.ref();
|
77 | }
|
78 | unref(): void {
|
79 | this.child.unref();
|
80 | }
|
81 | getChannelzRef(): SubchannelRef {
|
82 | return this.child.getChannelzRef();
|
83 | }
|
84 | getRealSubchannel(): Subchannel {
|
85 | return this.child.getRealSubchannel();
|
86 | }
|
87 | } |
\ | No newline at end of file |