1 |
|
2 | import { OrderedMap } from '@js-sdsl/ordered-map';
|
3 | import { ConnectivityState } from './connectivity-state';
|
4 | import { ChannelTrace } from './generated/grpc/channelz/v1/ChannelTrace';
|
5 | import { SubchannelAddress } from './subchannel-address';
|
6 | import { ChannelzDefinition, ChannelzHandlers } from './generated/grpc/channelz/v1/Channelz';
|
7 | export type TraceSeverity = 'CT_UNKNOWN' | 'CT_INFO' | 'CT_WARNING' | 'CT_ERROR';
|
8 | interface Ref {
|
9 | kind: EntityTypes;
|
10 | id: number;
|
11 | name: string;
|
12 | }
|
13 | export interface ChannelRef extends Ref {
|
14 | kind: EntityTypes.channel;
|
15 | }
|
16 | export interface SubchannelRef extends Ref {
|
17 | kind: EntityTypes.subchannel;
|
18 | }
|
19 | export interface ServerRef extends Ref {
|
20 | kind: EntityTypes.server;
|
21 | }
|
22 | export interface SocketRef extends Ref {
|
23 | kind: EntityTypes.socket;
|
24 | }
|
25 | interface TraceEvent {
|
26 | description: string;
|
27 | severity: TraceSeverity;
|
28 | timestamp: Date;
|
29 | childChannel?: ChannelRef;
|
30 | childSubchannel?: SubchannelRef;
|
31 | }
|
32 | export declare class ChannelzTraceStub {
|
33 | readonly events: TraceEvent[];
|
34 | readonly creationTimestamp: Date;
|
35 | readonly eventsLogged = 0;
|
36 | addTrace(): void;
|
37 | getTraceMessage(): ChannelTrace;
|
38 | }
|
39 | export declare class ChannelzTrace {
|
40 | events: TraceEvent[];
|
41 | creationTimestamp: Date;
|
42 | eventsLogged: number;
|
43 | constructor();
|
44 | addTrace(severity: TraceSeverity, description: string, child?: ChannelRef | SubchannelRef): void;
|
45 | getTraceMessage(): ChannelTrace;
|
46 | }
|
47 | export declare class ChannelzChildrenTracker {
|
48 | private channelChildren;
|
49 | private subchannelChildren;
|
50 | private socketChildren;
|
51 | private trackerMap;
|
52 | refChild(child: ChannelRef | SubchannelRef | SocketRef): void;
|
53 | unrefChild(child: ChannelRef | SubchannelRef | SocketRef): void;
|
54 | getChildLists(): ChannelzChildren;
|
55 | }
|
56 | export declare class ChannelzChildrenTrackerStub extends ChannelzChildrenTracker {
|
57 | refChild(): void;
|
58 | unrefChild(): void;
|
59 | }
|
60 | export declare class ChannelzCallTracker {
|
61 | callsStarted: number;
|
62 | callsSucceeded: number;
|
63 | callsFailed: number;
|
64 | lastCallStartedTimestamp: Date | null;
|
65 | addCallStarted(): void;
|
66 | addCallSucceeded(): void;
|
67 | addCallFailed(): void;
|
68 | }
|
69 | export declare class ChannelzCallTrackerStub extends ChannelzCallTracker {
|
70 | addCallStarted(): void;
|
71 | addCallSucceeded(): void;
|
72 | addCallFailed(): void;
|
73 | }
|
74 | export interface ChannelzChildren {
|
75 | channels: OrderedMap<number, {
|
76 | ref: ChannelRef;
|
77 | count: number;
|
78 | }>;
|
79 | subchannels: OrderedMap<number, {
|
80 | ref: SubchannelRef;
|
81 | count: number;
|
82 | }>;
|
83 | sockets: OrderedMap<number, {
|
84 | ref: SocketRef;
|
85 | count: number;
|
86 | }>;
|
87 | }
|
88 | export interface ChannelInfo {
|
89 | target: string;
|
90 | state: ConnectivityState;
|
91 | trace: ChannelzTrace | ChannelzTraceStub;
|
92 | callTracker: ChannelzCallTracker | ChannelzCallTrackerStub;
|
93 | children: ChannelzChildren;
|
94 | }
|
95 | export type SubchannelInfo = ChannelInfo;
|
96 | export interface ServerInfo {
|
97 | trace: ChannelzTrace;
|
98 | callTracker: ChannelzCallTracker;
|
99 | listenerChildren: ChannelzChildren;
|
100 | sessionChildren: ChannelzChildren;
|
101 | }
|
102 | export interface TlsInfo {
|
103 | cipherSuiteStandardName: string | null;
|
104 | cipherSuiteOtherName: string | null;
|
105 | localCertificate: Buffer | null;
|
106 | remoteCertificate: Buffer | null;
|
107 | }
|
108 | export interface SocketInfo {
|
109 | localAddress: SubchannelAddress | null;
|
110 | remoteAddress: SubchannelAddress | null;
|
111 | security: TlsInfo | null;
|
112 | remoteName: string | null;
|
113 | streamsStarted: number;
|
114 | streamsSucceeded: number;
|
115 | streamsFailed: number;
|
116 | messagesSent: number;
|
117 | messagesReceived: number;
|
118 | keepAlivesSent: number;
|
119 | lastLocalStreamCreatedTimestamp: Date | null;
|
120 | lastRemoteStreamCreatedTimestamp: Date | null;
|
121 | lastMessageSentTimestamp: Date | null;
|
122 | lastMessageReceivedTimestamp: Date | null;
|
123 | localFlowControlWindow: number | null;
|
124 | remoteFlowControlWindow: number | null;
|
125 | }
|
126 | interface ChannelEntry {
|
127 | ref: ChannelRef;
|
128 | getInfo(): ChannelInfo;
|
129 | }
|
130 | interface SubchannelEntry {
|
131 | ref: SubchannelRef;
|
132 | getInfo(): SubchannelInfo;
|
133 | }
|
134 | interface ServerEntry {
|
135 | ref: ServerRef;
|
136 | getInfo(): ServerInfo;
|
137 | }
|
138 | interface SocketEntry {
|
139 | ref: SocketRef;
|
140 | getInfo(): SocketInfo;
|
141 | }
|
142 | export declare const enum EntityTypes {
|
143 | channel = "channel",
|
144 | subchannel = "subchannel",
|
145 | server = "server",
|
146 | socket = "socket"
|
147 | }
|
148 | export type RefByType<T extends EntityTypes> = T extends EntityTypes.channel ? ChannelRef : T extends EntityTypes.server ? ServerRef : T extends EntityTypes.socket ? SocketRef : T extends EntityTypes.subchannel ? SubchannelRef : never;
|
149 | export type EntryByType<T extends EntityTypes> = T extends EntityTypes.channel ? ChannelEntry : T extends EntityTypes.server ? ServerEntry : T extends EntityTypes.socket ? SocketEntry : T extends EntityTypes.subchannel ? SubchannelEntry : never;
|
150 | export type InfoByType<T extends EntityTypes> = T extends EntityTypes.channel ? ChannelInfo : T extends EntityTypes.subchannel ? SubchannelInfo : T extends EntityTypes.server ? ServerInfo : T extends EntityTypes.socket ? SocketInfo : never;
|
151 | export declare const registerChannelzChannel: (name: string, getInfo: () => ChannelInfo, channelzEnabled: boolean) => ChannelRef;
|
152 | export declare const registerChannelzSubchannel: (name: string, getInfo: () => ChannelInfo, channelzEnabled: boolean) => SubchannelRef;
|
153 | export declare const registerChannelzServer: (name: string, getInfo: () => ServerInfo, channelzEnabled: boolean) => ServerRef;
|
154 | export declare const registerChannelzSocket: (name: string, getInfo: () => SocketInfo, channelzEnabled: boolean) => SocketRef;
|
155 | export declare function unregisterChannelzRef(ref: ChannelRef | SubchannelRef | ServerRef | SocketRef): void;
|
156 | export declare function getChannelzHandlers(): ChannelzHandlers;
|
157 | export declare function getChannelzServiceDefinition(): ChannelzDefinition;
|
158 | export declare function setup(): void;
|
159 | export {};
|