Skip to content

Commit 4cc773f

Browse files
committed
feat(Tenant): cdc streams info
1 parent 4b2ed9a commit 4cc773f

File tree

8 files changed

+119
-4
lines changed

8 files changed

+119
-4
lines changed

Diff for: src/components/InfoViewer/formatters/common.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type {TDirEntry} from '../../../types/api/schema';
2+
import {formatDateTime} from '../../../utils';
3+
4+
import {createInfoFormatter} from '../utils';
5+
6+
export const formatCommonItem = createInfoFormatter<TDirEntry>({
7+
values: {
8+
PathType: (value) => value?.substring('EPathType'.length),
9+
CreateStep: formatDateTime,
10+
},
11+
labels: {
12+
PathType: 'Type',
13+
CreateStep: 'Created',
14+
},
15+
});

Diff for: src/components/InfoViewer/formatters/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './common';
12
export * from './schema';

Diff for: src/components/InfoViewer/formatters/schema.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
TCdcStreamDescription,
23
TIndexDescription,
34
} from '../../../types/api/schema';
45

@@ -16,3 +17,10 @@ export const formatTableIndexItem = createInfoFormatter<TIndexDescription>({
1617
DataColumnNames: 'Includes',
1718
},
1819
});
20+
21+
export const formatCdcStreamItem = createInfoFormatter<TCdcStreamDescription>({
22+
values: {
23+
Mode: (value) => value?.substring('ECdcStreamMode'.length),
24+
Format: (value) => value?.substring('ECdcStreamFormat'.length),
25+
},
26+
});
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import type {TEvDescribeSchemeResult, TCdcStreamDescription} from '../../../types/api/schema';
2+
3+
import {formatCdcStreamItem, formatCommonItem} from '../formatters';
4+
import {InfoViewer, InfoViewerItem} from '..';
5+
6+
const DISPLAYED_FIELDS: Set<keyof TCdcStreamDescription> = new Set([
7+
'Mode',
8+
'Format',
9+
]);
10+
11+
interface CDCStreamInfoProps {
12+
data?: TEvDescribeSchemeResult;
13+
}
14+
15+
export const CDCStreamInfo = ({data}: CDCStreamInfoProps) => {
16+
if (!data) {
17+
return (
18+
<div className="error">No CDC Stream data</div>
19+
);
20+
}
21+
22+
const TableIndex = data.PathDescription?.CdcStreamDescription;
23+
const info: Array<InfoViewerItem> = [];
24+
25+
info.push(formatCommonItem('PathType', data.PathDescription?.Self?.PathType));
26+
info.push(formatCommonItem('CreateStep', data.PathDescription?.Self?.CreateStep));
27+
28+
let key: keyof TCdcStreamDescription;
29+
for (key in TableIndex) {
30+
if (DISPLAYED_FIELDS.has(key)) {
31+
info.push(formatCdcStreamItem(key, TableIndex?.[key]));
32+
}
33+
}
34+
35+
return (
36+
<>
37+
{info.length ? (
38+
<InfoViewer info={info}></InfoViewer>
39+
) : (
40+
<>Empty</>
41+
)}
42+
</>
43+
);
44+
};

Diff for: src/components/InfoViewer/schemaInfo/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './CDCStreamInfo';
12
export * from './TableIndexInfo';

Diff for: src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export const TABLE_PAGES = [overview, topShards, graph, tablets, hotKeys, descri
8181

8282
export const DIR_PAGES = [overview, topShards, describe];
8383

84+
export const TOPIC_PAGES = [overview, describe];
85+
8486
// verbose mapping to guarantee correct tabs for new path types
8587
// TS will error when a new type is added but not mapped here
8688
const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
@@ -95,7 +97,8 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
9597

9698
[EPathType.EPathTypeDir]: DIR_PAGES,
9799
[EPathType.EPathTypeTableIndex]: DIR_PAGES,
98-
[EPathType.EPathTypeCdcStream]: DIR_PAGES,
100+
101+
[EPathType.EPathTypeCdcStream]: TOPIC_PAGES,
99102
};
100103

101104
export const getPagesByType = (type?: EPathType) =>

Diff for: src/containers/Tenant/Diagnostics/Overview/Overview.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {Loader} from '@yandex-cloud/uikit';
66

77
//@ts-ignore
88
import SchemaInfoViewer from '../../Schema/SchemaInfoViewer/SchemaInfoViewer';
9-
import {TableIndexInfo} from '../../../../components/InfoViewer/schemaInfo';
9+
import {
10+
CDCStreamInfo,
11+
TableIndexInfo,
12+
} from '../../../../components/InfoViewer/schemaInfo';
1013

1114
import {EPathType} from '../../../../types/api/schema';
1215
import {isColumnEntityType, isTableType} from '../../utils/schema';
@@ -125,7 +128,7 @@ function Overview(props: OverviewProps) {
125128
[EPathType.EPathTypeExtSubDomain]: undefined,
126129
[EPathType.EPathTypeColumnStore]: undefined,
127130
[EPathType.EPathTypeColumnTable]: undefined,
128-
[EPathType.EPathTypeCdcStream]: undefined,
131+
[EPathType.EPathTypeCdcStream]: () => <CDCStreamInfo data={schemaData} />,
129132
};
130133

131134
return (props.type && pathTypeToComponent[props.type]?.()) || (

Diff for: src/types/api/schema.ts

+41-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ interface TPathDescription {
5656
ColumnTableDescription?: unknown;
5757

5858
TableIndex?: TIndexDescription;
59+
60+
CdcStreamDescription?: TCdcStreamDescription;
5961
}
6062

61-
interface TDirEntry {
63+
export interface TDirEntry {
6264
Name?: string;
6365
/** uint64 */
6466
PathId?: string;
@@ -208,6 +210,44 @@ export interface TIndexDescription {
208210
DataSize?: string;
209211
}
210212

213+
enum ECdcStreamMode {
214+
ECdcStreamModeInvalid = 'ECdcStreamModeInvalid',
215+
ECdcStreamModeKeysOnly = 'ECdcStreamModeKeysOnly',
216+
ECdcStreamModeUpdate = 'ECdcStreamModeUpdate',
217+
ECdcStreamModeNewImage = 'ECdcStreamModeNewImage',
218+
ECdcStreamModeOldImage = 'ECdcStreamModeOldImage',
219+
ECdcStreamModeNewAndOldImages = 'ECdcStreamModeNewAndOldImages',
220+
}
221+
222+
enum ECdcStreamFormat {
223+
ECdcStreamFormatInvalid = 'ECdcStreamFormatInvalid',
224+
ECdcStreamFormatProto = 'ECdcStreamFormatProto',
225+
ECdcStreamFormatJson = 'ECdcStreamFormatJson',
226+
}
227+
228+
enum ECdcStreamState {
229+
ECdcStreamStateInvalid = 'ECdcStreamStateInvalid',
230+
ECdcStreamStateReady = 'ECdcStreamStateReady',
231+
ECdcStreamStateDisabled = 'ECdcStreamStateDisabled',
232+
}
233+
234+
interface TPathID {
235+
/** fixed64 */
236+
OwnerId?: string;
237+
/** uint64 */
238+
LocalId?: string;
239+
}
240+
241+
export interface TCdcStreamDescription {
242+
Name?: string;
243+
Mode?: ECdcStreamMode;
244+
Format?: ECdcStreamFormat;
245+
PathId?: TPathID;
246+
State?: ECdcStreamState;
247+
/** uint64 */
248+
SchemaVersion?: string;
249+
}
250+
211251
// incomplete
212252
export enum EPathType {
213253
EPathTypeInvalid = 'EPathTypeInvalid',

0 commit comments

Comments
 (0)