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 | ) => void;
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | export interface SubchannelInterface {
|
38 | getConnectivityState(): ConnectivityState;
|
39 | addConnectivityStateListener(listener: ConnectivityStateListener): void;
|
40 | removeConnectivityStateListener(listener: ConnectivityStateListener): void;
|
41 | startConnecting(): void;
|
42 | getAddress(): string;
|
43 | ref(): void;
|
44 | unref(): void;
|
45 | getChannelzRef(): SubchannelRef;
|
46 | |
47 |
|
48 |
|
49 | getRealSubchannel(): Subchannel;
|
50 | }
|
51 |
|
52 | export abstract class BaseSubchannelWrapper implements SubchannelInterface {
|
53 | constructor(protected child: SubchannelInterface) {}
|
54 |
|
55 | getConnectivityState(): ConnectivityState {
|
56 | return this.child.getConnectivityState();
|
57 | }
|
58 | addConnectivityStateListener(listener: ConnectivityStateListener): void {
|
59 | this.child.addConnectivityStateListener(listener);
|
60 | }
|
61 | removeConnectivityStateListener(listener: ConnectivityStateListener): void {
|
62 | this.child.removeConnectivityStateListener(listener);
|
63 | }
|
64 | startConnecting(): void {
|
65 | this.child.startConnecting();
|
66 | }
|
67 | getAddress(): string {
|
68 | return this.child.getAddress();
|
69 | }
|
70 | ref(): void {
|
71 | this.child.ref();
|
72 | }
|
73 | unref(): void {
|
74 | this.child.unref();
|
75 | }
|
76 | getChannelzRef(): SubchannelRef {
|
77 | return this.child.getChannelzRef();
|
78 | }
|
79 | getRealSubchannel(): Subchannel {
|
80 | return this.child.getRealSubchannel();
|
81 | }
|
82 | } |
\ | No newline at end of file |