Skip to content

Commit d69c9e8

Browse files
chore: cover describe consumer and topic with types
1 parent aa5e805 commit d69c9e8

File tree

5 files changed

+421
-7
lines changed

5 files changed

+421
-7
lines changed

src/store/reducers/describe.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {createSelector, Selector} from 'reselect';
22
import {Reducer} from 'redux';
33

44
import '../../services/api';
5-
import {IConsumer} from '../../types/api/consumers';
65
import {
76
IDescribeRootStateSlice,
87
IDescribeState,
@@ -100,6 +99,10 @@ const selectConsumersNames = (state: IDescribeRootStateSlice, path?: string) =>
10099
? state.describe.data[path]?.PathDescription?.PersQueueGroup?.PQTabletConfig?.ReadRules
101100
: undefined;
102101

102+
interface IConsumer {
103+
name: string;
104+
}
105+
103106
export const selectConsumers: Selector<IDescribeRootStateSlice, IConsumer[], [string | undefined]> =
104107
createSelector(selectConsumersNames, (names = []) => names.map((name) => ({name})));
105108

src/types/api/consumer.ts

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
/* eslint-disable camelcase */
2+
3+
/**
4+
* endpoint: /json/describe_consumer
5+
*
6+
* source: https://github.com/ydb-platform/ydb/blob/main/ydb/public/api/protos/ydb_topic.proto
7+
*
8+
* Original proto file doesn't specify optional fields, so every field is considered optional
9+
*/
10+
export interface DescribeConsumerResult {
11+
self?: Entry;
12+
consumer?: Consumer;
13+
partitions?: PartitionInfo[];
14+
}
15+
16+
/** Partition info types differs for consumer and topic, although they are very similar */
17+
export interface PartitionInfo {
18+
/** int64 */
19+
partition_id?: string;
20+
21+
/** Is partition open for write. */
22+
active?: boolean;
23+
24+
/**
25+
* int64
26+
*
27+
* Ids of partitions which was formed when this partition was split or merged.
28+
*/
29+
child_partition_ids?: string[];
30+
31+
/**
32+
* int64
33+
*
34+
* Ids of partitions from which this partition was formed by split or merge.
35+
*/
36+
parent_partition_ids?: string[];
37+
38+
/** Stats for partition, filled only when include_stats in request is true. */
39+
partition_stats?: PartitionStats;
40+
41+
/** Stats for consumer of this partition, filled only when include_stats in request is true. */
42+
partition_consumer_stats?: PartitionConsumerStats;
43+
}
44+
45+
interface PartitionConsumerStats {
46+
/**
47+
* int64
48+
*
49+
* Last read offset from this partition.
50+
*/
51+
last_read_offset?: string;
52+
53+
/**
54+
* int64
55+
*
56+
* Committed offset for this partition.
57+
*/
58+
committed_offset?: string;
59+
60+
/** Reading this partition read session identifier. */
61+
read_session_id?: string;
62+
63+
/**
64+
* google.protobuf.Timestamp
65+
*
66+
* Timestamp of providing this partition to this session by server.
67+
*/
68+
partition_read_session_create_time?: string;
69+
70+
/**
71+
* google.protobuf.Timestamp
72+
*
73+
* Timestamp of last read from this partition. */
74+
last_read_time?: string;
75+
76+
/**
77+
* google.protobuf.Duration
78+
*
79+
* Maximum of differences between timestamp of read and write timestamp for all messages, read during last minute.
80+
*/
81+
max_read_time_lag?: string;
82+
83+
/**
84+
* google.protobuf.Duration
85+
*
86+
* Maximum of differences between write timestamp and create timestamp for all messages, read during last minute.
87+
*/
88+
max_write_time_lag?: string;
89+
90+
/** How much bytes were read during several windows statistics from this partiton. */
91+
bytes_read?: MultipleWindowsStat;
92+
93+
/** Read session name, provided by client. */
94+
reader_name?: string;
95+
96+
/** Host where read session connected. */
97+
connection_node_id?: number;
98+
}
99+
100+
export interface PartitionStats {
101+
/** Partition contains messages with offsets in range [start, end). */
102+
partition_offsets?: OffsetsRange;
103+
104+
/**
105+
* int64
106+
*
107+
* Approximate size of partition.
108+
*/
109+
store_size_bytes?: string;
110+
111+
/**
112+
* google.protobuf.Timestamp
113+
*
114+
* Timestamp of last write.
115+
*/
116+
last_write_time?: string;
117+
118+
/**
119+
* google.protobuf.Duration
120+
*
121+
* Maximum of differences between write timestamp and create timestamp for all messages, written during last minute.
122+
*/
123+
max_write_time_lag?: string;
124+
125+
/** How much bytes were written during several windows in this partition. */
126+
bytes_written?: MultipleWindowsStat;
127+
128+
/** Host where tablet for this partition works. Useful for debugging purposes. */
129+
partition_node_id?: number;
130+
}
131+
132+
interface OffsetsRange {
133+
/** int64 */
134+
start?: string;
135+
/** int64 */
136+
end?: string;
137+
}
138+
139+
export interface Consumer {
140+
/** Must have valid not empty name as a key. */
141+
name?: string;
142+
143+
/** Consumer may be marked as 'important'. It means messages for this consumer will never expire due to retention. */
144+
important?: boolean;
145+
146+
/**
147+
* google.protobuf.Timestamp
148+
*
149+
* All messages with smaller server written_at timestamp will be skipped.
150+
*/
151+
read_from?: string;
152+
153+
/**
154+
* List of supported codecs by this consumer.
155+
*
156+
* supported_codecs on topic must be contained inside this list.
157+
*/
158+
supported_codecs?: SupportedCodecs;
159+
160+
/** Attributes of consumer */
161+
attributes?: Record<string, string>;
162+
163+
/** Filled only when requested statistics in Describe*Request. */
164+
consumer_stats?: ConsumerStats;
165+
}
166+
167+
interface ConsumerStats {
168+
/**
169+
* google.protobuf.Timestamp
170+
*
171+
* Minimal timestamp of last read from partitions.
172+
*/
173+
min_partitions_last_read_time?: string;
174+
175+
/**
176+
* google.protobuf.Duration
177+
*
178+
* Maximum of differences between timestamp of read and write timestamp for all messages, read during last minute.
179+
*/
180+
max_read_time_lag?: string;
181+
182+
/**
183+
* google.protobuf.Duration
184+
*
185+
* Maximum of differences between write timestamp and create timestamp for all messages, read during last minute.
186+
*/
187+
max_write_time_lag?: string;
188+
189+
/** Bytes read stastics. */
190+
bytes_read?: MultipleWindowsStat;
191+
}
192+
193+
export interface MultipleWindowsStat {
194+
/** int64 */
195+
per_minute?: string;
196+
/** int64 */
197+
per_hour?: string;
198+
/** int64 */
199+
per_day?: string;
200+
}
201+
202+
export interface SupportedCodecs {
203+
/** List of supported codecs. */
204+
codecs?: number[];
205+
}
206+
207+
export interface Entry {
208+
/** For consumer will be topic-name/consumer-name */
209+
name?: string;
210+
211+
owner?: string;
212+
type?: Type;
213+
effective_permissions?: Permissions[];
214+
permissions?: Permissions[];
215+
216+
/**
217+
* uint64
218+
*
219+
* Size of entry in bytes. Currently filled for:
220+
* - TABLE;
221+
* - DATABASE.
222+
*
223+
* Empty (zero) in other cases.
224+
*/
225+
size_bytes?: string;
226+
227+
/** Virtual timestamp when the object was created */
228+
created_at?: VirtualTimestamp;
229+
}
230+
231+
interface Permissions {
232+
subject?: string;
233+
permission_names?: string[];
234+
}
235+
236+
interface VirtualTimestamp {
237+
/** uint64 */
238+
plan_step?: string;
239+
/** uint64 */
240+
tx_id?: string;
241+
}
242+
243+
enum Type {
244+
TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED',
245+
DIRECTORY = 'DIRECTORY',
246+
TABLE = 'TABLE',
247+
PERS_QUEUE_GROUP = 'PERS_QUEUE_GROUP',
248+
DATABASE = 'DATABASE',
249+
RTMR_VOLUME = 'RTMR_VOLUME',
250+
BLOCK_STORE_VOLUME = 'BLOCK_STORE_VOLUME',
251+
COORDINATION_NODE = 'COORDINATION_NODE',
252+
COLUMN_STORE = 'COLUMN_STORE ',
253+
COLUMN_TABLE = 'COLUMN_TABLE ',
254+
SEQUENCE = 'SEQUENCE ',
255+
REPLICATION = 'REPLICATION ',
256+
TOPIC = 'TOPIC ',
257+
}

src/types/api/consumers.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)