ITADN

Implement DescribeConfigs Admin Call to read topic/broker config

#134Pull Requestchikko80 创建于 2025-09-23
C
chikko80commented
### Title Add DescribeConfigs request/response and admin helper ### Summary This change introduces full protocol support for DescribeConfigs (request/response) with a typed API and adds an admin helper to call it. It enables querying broker/topic configs without external tooling, and optionally provides a typed `get_value` helper behind the `serde` feature. ### Motivation - Provide native Rust support for the Kafka/Redpanda DescribeConfigs API - Allow users to fetch configuration for resources (brokers, topics) programmatically ### Changes - Protocol: - Added request/response modules under `protocol/describe_configs/` (API key 32, v1 subset). - Request: `DescribeConfigsRequest` with `add_resource(ConfigResource)`. - Typed resources via `request::ConfigResource::{Broker, Topic}` instead of raw integers. - Response: parses resources/configs/synonyms (`name`, `value`, `read_only`, `is_default`, `is_sensitive`, `synonyms`). - Optional (feature `serde`): `DescribeConfigsResponse::get_value<T>(resource_name, key) -> Option<T>` for convenient typed access. - Admin helper: - `admin::describe_configs(conn, correlation_id, client_id, resources: Vec<protocol::describe_configs::request::ConfigResource<'_>>)` returns `protocol::DescribeConfigsResponse`. - Prelude: - Re-exported `describe_configs` and protocol modules under `samsa::prelude::*` and `samsa::prelude::protocol`. ### Usage Example ```rust use samsa::prelude::*; use samsa::prelude::protocol::describe_configs::request::ConfigResource; let resources = vec![ConfigResource::Topic { resource_name: "my-topic", config_names: vec!["cleanup.policy", "retention.ms"], }]; let resp = describe_configs(conn, correlation_id, client_id, resources).await?; for r in resp.resources { /* ... */ } // Optional (feature = "serde"): typed access #[cfg(feature = "serde")] { let retention_ms: Option<i64> = resp.get_value("my-topic", "retention.ms"); } ``` ### Testing - Integration tests in `tests/describe_configs.rs` for topic and broker configs. - Unit test for `get_value` behind the `serde` feature flag. - Verified end-to-end via the admin helper. ### Backward Compatibility - Pure addition. No breaking changes to existing APIs. ### Checklist - [x] Request encoder and response parser - [x] Admin helper - [x] Docs and examples - [x] Tests
合并状态:未合并 2 条评论