Skip to main content

kafka_client_engine/admin/describe_streams_group/result/
value.rs

1//! Stable API-89 topology, task, and scalar result values.
2
3/// One exact key-value pair.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct DescribeStreamsGroupKeyValue {
6    pub(super) key: String,
7    pub(super) value: String,
8}
9
10impl DescribeStreamsGroupKeyValue {
11    /// Creates one exact pair.
12    pub const fn new(key: String, value: String) -> Self {
13        Self { key, value }
14    }
15
16    /// Consumes this pair into exact parts.
17    pub fn into_parts(self) -> (String, String) {
18        (self.key, self.value)
19    }
20}
21
22/// One streams topology topic and its creation policy.
23#[derive(Clone, Debug, Eq, PartialEq)]
24pub struct DescribeStreamsGroupTopicInfo {
25    pub(super) name: String,
26    pub(super) partitions: i32,
27    pub(super) replication_factor: i16,
28    pub(super) configs: Vec<DescribeStreamsGroupKeyValue>,
29}
30
31impl DescribeStreamsGroupTopicInfo {
32    /// Creates one exact topic description.
33    pub const fn new(
34        name: String,
35        partitions: i32,
36        replication_factor: i16,
37        configs: Vec<DescribeStreamsGroupKeyValue>,
38    ) -> Self {
39        Self {
40            name,
41            partitions,
42            replication_factor,
43            configs,
44        }
45    }
46
47    /// Consumes this topic into exact parts.
48    pub fn into_parts(self) -> (String, i32, i16, Vec<DescribeStreamsGroupKeyValue>) {
49        (
50            self.name,
51            self.partitions,
52            self.replication_factor,
53            self.configs,
54        )
55    }
56}
57
58/// One initialized streams subtopology.
59#[derive(Clone, Debug, Eq, PartialEq)]
60pub struct DescribeStreamsGroupSubtopology {
61    pub(super) subtopology_id: String,
62    pub(super) source_topics: Vec<String>,
63    pub(super) repartition_sink_topics: Vec<String>,
64    pub(super) state_changelog_topics: Vec<DescribeStreamsGroupTopicInfo>,
65    pub(super) repartition_source_topics: Vec<DescribeStreamsGroupTopicInfo>,
66}
67
68impl DescribeStreamsGroupSubtopology {
69    /// Creates one exact initialized subtopology.
70    pub const fn new(
71        subtopology_id: String,
72        source_topics: Vec<String>,
73        repartition_sink_topics: Vec<String>,
74        state_changelog_topics: Vec<DescribeStreamsGroupTopicInfo>,
75        repartition_source_topics: Vec<DescribeStreamsGroupTopicInfo>,
76    ) -> Self {
77        Self {
78            subtopology_id,
79            source_topics,
80            repartition_sink_topics,
81            state_changelog_topics,
82            repartition_source_topics,
83        }
84    }
85
86    /// Consumes this subtopology into exact parts.
87    #[allow(clippy::type_complexity)]
88    pub fn into_parts(
89        self,
90    ) -> (
91        String,
92        Vec<String>,
93        Vec<String>,
94        Vec<DescribeStreamsGroupTopicInfo>,
95        Vec<DescribeStreamsGroupTopicInfo>,
96    ) {
97        (
98            self.subtopology_id,
99            self.source_topics,
100            self.repartition_sink_topics,
101            self.state_changelog_topics,
102            self.repartition_source_topics,
103        )
104    }
105}
106
107/// Current initialized streams topology.
108#[derive(Clone, Debug, Eq, PartialEq)]
109pub struct DescribeStreamsGroupTopology {
110    pub(super) epoch: i32,
111    pub(super) subtopologies: Option<Vec<DescribeStreamsGroupSubtopology>>,
112}
113
114impl DescribeStreamsGroupTopology {
115    /// Creates one exact initialized topology.
116    pub const fn new(
117        epoch: i32,
118        subtopologies: Option<Vec<DescribeStreamsGroupSubtopology>>,
119    ) -> Self {
120        Self {
121            epoch,
122            subtopologies,
123        }
124    }
125
126    /// Consumes this topology into exact parts.
127    pub fn into_parts(self) -> (i32, Option<Vec<DescribeStreamsGroupSubtopology>>) {
128        (self.epoch, self.subtopologies)
129    }
130}
131
132/// Optional interactive-query endpoint.
133#[derive(Clone, Debug, Eq, PartialEq)]
134pub struct DescribeStreamsGroupEndpoint {
135    pub(super) host: String,
136    pub(super) port: u16,
137}
138
139impl DescribeStreamsGroupEndpoint {
140    /// Creates one exact endpoint.
141    pub const fn new(host: String, port: u16) -> Self {
142        Self { host, port }
143    }
144
145    /// Consumes this endpoint into exact parts.
146    pub fn into_parts(self) -> (String, u16) {
147        (self.host, self.port)
148    }
149}
150
151/// One changelog offset for a streams task.
152#[derive(Clone, Debug, Eq, PartialEq)]
153pub struct DescribeStreamsGroupTaskOffset {
154    pub(super) subtopology_id: String,
155    pub(super) partition: i32,
156    pub(super) offset: i64,
157}
158
159impl DescribeStreamsGroupTaskOffset {
160    /// Creates one exact task offset.
161    pub const fn new(subtopology_id: String, partition: i32, offset: i64) -> Self {
162        Self {
163            subtopology_id,
164            partition,
165            offset,
166        }
167    }
168
169    /// Consumes this task offset into exact parts.
170    pub fn into_parts(self) -> (String, i32, i64) {
171        (self.subtopology_id, self.partition, self.offset)
172    }
173}
174
175/// One subtopology's assigned task partitions.
176#[derive(Clone, Debug, Eq, PartialEq)]
177pub struct DescribeStreamsGroupTaskIds {
178    pub(super) subtopology_id: String,
179    pub(super) partitions: Vec<i32>,
180}
181
182impl DescribeStreamsGroupTaskIds {
183    /// Creates one exact task partition group.
184    pub const fn new(subtopology_id: String, partitions: Vec<i32>) -> Self {
185        Self {
186            subtopology_id,
187            partitions,
188        }
189    }
190
191    /// Consumes this task group into exact parts.
192    pub fn into_parts(self) -> (String, Vec<i32>) {
193        (self.subtopology_id, self.partitions)
194    }
195}
196
197/// Current or target task assignment for one member.
198#[derive(Clone, Debug, Eq, PartialEq)]
199#[allow(
200    clippy::struct_field_names,
201    reason = "the field names preserve Kafka's three distinct task classes"
202)]
203pub struct DescribeStreamsGroupAssignment {
204    pub(super) active_tasks: Vec<DescribeStreamsGroupTaskIds>,
205    pub(super) standby_tasks: Vec<DescribeStreamsGroupTaskIds>,
206    pub(super) warmup_tasks: Vec<DescribeStreamsGroupTaskIds>,
207}
208
209impl DescribeStreamsGroupAssignment {
210    /// Creates one exact task assignment.
211    pub const fn new(
212        active_tasks: Vec<DescribeStreamsGroupTaskIds>,
213        standby_tasks: Vec<DescribeStreamsGroupTaskIds>,
214        warmup_tasks: Vec<DescribeStreamsGroupTaskIds>,
215    ) -> Self {
216        Self {
217            active_tasks,
218            standby_tasks,
219            warmup_tasks,
220        }
221    }
222
223    /// Consumes this assignment into exact task classes.
224    #[allow(clippy::type_complexity)]
225    pub fn into_parts(
226        self,
227    ) -> (
228        Vec<DescribeStreamsGroupTaskIds>,
229        Vec<DescribeStreamsGroupTaskIds>,
230        Vec<DescribeStreamsGroupTaskIds>,
231    ) {
232        (self.active_tasks, self.standby_tasks, self.warmup_tasks)
233    }
234}