UNPKG

5.93 kBTypeScriptView Raw
1/// <reference types="node" />
2import { OrderedMap } from '@js-sdsl/ordered-map';
3import { ConnectivityState } from './connectivity-state';
4import { ChannelTrace } from './generated/grpc/channelz/v1/ChannelTrace';
5import { SubchannelAddress } from './subchannel-address';
6import { ChannelzDefinition, ChannelzHandlers } from './generated/grpc/channelz/v1/Channelz';
7export type TraceSeverity = 'CT_UNKNOWN' | 'CT_INFO' | 'CT_WARNING' | 'CT_ERROR';
8interface Ref {
9 kind: EntityTypes;
10 id: number;
11 name: string;
12}
13export interface ChannelRef extends Ref {
14 kind: EntityTypes.channel;
15}
16export interface SubchannelRef extends Ref {
17 kind: EntityTypes.subchannel;
18}
19export interface ServerRef extends Ref {
20 kind: EntityTypes.server;
21}
22export interface SocketRef extends Ref {
23 kind: EntityTypes.socket;
24}
25interface TraceEvent {
26 description: string;
27 severity: TraceSeverity;
28 timestamp: Date;
29 childChannel?: ChannelRef;
30 childSubchannel?: SubchannelRef;
31}
32export declare class ChannelzTraceStub {
33 readonly events: TraceEvent[];
34 readonly creationTimestamp: Date;
35 readonly eventsLogged = 0;
36 addTrace(): void;
37 getTraceMessage(): ChannelTrace;
38}
39export 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}
47export 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}
56export declare class ChannelzChildrenTrackerStub extends ChannelzChildrenTracker {
57 refChild(): void;
58 unrefChild(): void;
59}
60export 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}
69export declare class ChannelzCallTrackerStub extends ChannelzCallTracker {
70 addCallStarted(): void;
71 addCallSucceeded(): void;
72 addCallFailed(): void;
73}
74export 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}
88export interface ChannelInfo {
89 target: string;
90 state: ConnectivityState;
91 trace: ChannelzTrace | ChannelzTraceStub;
92 callTracker: ChannelzCallTracker | ChannelzCallTrackerStub;
93 children: ChannelzChildren;
94}
95export type SubchannelInfo = ChannelInfo;
96export interface ServerInfo {
97 trace: ChannelzTrace;
98 callTracker: ChannelzCallTracker;
99 listenerChildren: ChannelzChildren;
100 sessionChildren: ChannelzChildren;
101}
102export interface TlsInfo {
103 cipherSuiteStandardName: string | null;
104 cipherSuiteOtherName: string | null;
105 localCertificate: Buffer | null;
106 remoteCertificate: Buffer | null;
107}
108export 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}
126interface ChannelEntry {
127 ref: ChannelRef;
128 getInfo(): ChannelInfo;
129}
130interface SubchannelEntry {
131 ref: SubchannelRef;
132 getInfo(): SubchannelInfo;
133}
134interface ServerEntry {
135 ref: ServerRef;
136 getInfo(): ServerInfo;
137}
138interface SocketEntry {
139 ref: SocketRef;
140 getInfo(): SocketInfo;
141}
142export declare const enum EntityTypes {
143 channel = "channel",
144 subchannel = "subchannel",
145 server = "server",
146 socket = "socket"
147}
148export 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;
149export 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;
150export 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;
151export declare const registerChannelzChannel: (name: string, getInfo: () => ChannelInfo, channelzEnabled: boolean) => ChannelRef;
152export declare const registerChannelzSubchannel: (name: string, getInfo: () => ChannelInfo, channelzEnabled: boolean) => SubchannelRef;
153export declare const registerChannelzServer: (name: string, getInfo: () => ServerInfo, channelzEnabled: boolean) => ServerRef;
154export declare const registerChannelzSocket: (name: string, getInfo: () => SocketInfo, channelzEnabled: boolean) => SocketRef;
155export declare function unregisterChannelzRef(ref: ChannelRef | SubchannelRef | ServerRef | SocketRef): void;
156export declare function getChannelzHandlers(): ChannelzHandlers;
157export declare function getChannelzServiceDefinition(): ChannelzDefinition;
158export declare function setup(): void;
159export {};