Skip to main content

confluent_kafka/admin/options/
delete_consumer_groups_options.rs

1// Copyright 2025 Confluent Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Options for `Admin::delete_consumer_groups`.
16
17/// Options for `Admin::delete_consumer_groups`.
18#[derive(Clone, Debug, Default)]
19#[doc(alias = "org.apache.kafka.clients.admin.DeleteConsumerGroupsOptions")]
20pub struct DeleteConsumerGroupsOptions {
21    timeout_ms: Option<i32>,
22}
23
24impl DeleteConsumerGroupsOptions {
25    /// Creates default options.
26    #[doc(alias = "org.apache.kafka.clients.admin.DeleteConsumerGroupsOptions#DeleteConsumerGroupsOptions")]
27    pub fn new() -> Self {
28        Self::default()
29    }
30
31    /// Set the timeout in milliseconds for this operation, or `None` if the default
32    /// API timeout for the `AdminClient` should be used.
33    ///
34    /// # Arguments
35    ///
36    /// - `timeout_ms` - the timeout in milliseconds, or `None` for the default API timeout.
37    ///
38    /// # Returns
39    ///
40    /// This `DeleteConsumerGroupsOptions` instance.
41    #[must_use]
42    #[doc(alias = "org.apache.kafka.clients.admin.AbstractOptions#timeoutMs")]
43    pub fn set_timeout_ms(mut self, timeout_ms: Option<i32>) -> Self {
44        self.timeout_ms = timeout_ms;
45        self
46    }
47
48    /// Returns the timeout in milliseconds for this operation, or `None` if the
49    /// default API timeout for the `AdminClient` should be used.
50    #[doc(alias = "org.apache.kafka.clients.admin.AbstractOptions#timeoutMs")]
51    pub fn timeout_ms(&self) -> Option<i32> {
52        self.timeout_ms
53    }
54}
55
56#[cfg(test)]
57mod tests {
58    use super::*;
59
60    #[test]
61    fn defaults_and_setter() {
62        let options = DeleteConsumerGroupsOptions::new();
63        assert_eq!(options.timeout_ms(), None);
64        let options = options.set_timeout_ms(Some(100));
65        assert_eq!(options.timeout_ms(), Some(100));
66    }
67}