hubcio commented on code in PR #4249:
URL: https://github.com/apache/iggy/pull/4249#discussion_r4061294639
##########
core/sdk/src/clients/client.rs:
##########
@@ -722,8 +723,8 @@ impl IggyClient {
self.client.clone(),
name.to_owned(),
Consumer::group(name.try_into()?),
Review Comment:
warning: this still parses a digit-only group name as a numeric id, but the
join at consumer.rs:1437 now goes by name, so a member joins one address and
polls, syncs and leaves by another. use `Identifier::named(name)?` here too.
##########
core/integration/tests/sdk/stream_builder.rs:
##########
@@ -0,0 +1,70 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use iggy::prelude::*;
+use iggy::stream_builder::{IggyConsumerConfig, IggyStreamConsumer};
+use integration::iggy_harness;
+
+const STREAM_NAME: &str = "stream-builder-stream";
Review Comment:
warning: both names are non-numeric, so the old numeric-first parsing and
`Identifier::named` give the same identifier and this passes before and after
the fix. add a case with a digit-only name like "42" (not "0", ids start at 0).
##########
core/sdk/src/stream_builder/config/config_iggy_consumer.rs:
##########
@@ -187,13 +172,11 @@ impl IggyConsumerConfig {
batch_length: u32,
polling_interval: IggyDuration,
) -> Result<Self, IggyError> {
- let stream_id = Identifier::from_str_value(stream)?;
- let topic_id = Identifier::from_str_value(topic)?;
+ Identifier::named(stream)?;
Review Comment:
nit: the result is dropped, so this only rejects an empty or over-long name.
either say so in a comment or drop both calls and the `Identifier` import, the
build path runs the same check anyway.
also at config_iggy_producer.rs:127.
##########
core/sdk/src/stream_builder/config/config_iggy_stream.rs:
##########
@@ -85,22 +85,6 @@ impl IggyStreamConfig {
pub fn producer_config(&self) -> &IggyProducerConfig {
&self.producer_config
}
-
- pub fn stream_id(&self) -> &Identifier {
- self.producer_config.stream_id()
- }
-
- pub fn stream_name(&self) -> &str {
- self.producer_config.stream_name()
- }
-
- pub fn topic_id(&self) -> &Identifier {
- self.producer_config.topic_id()
- }
-
- pub fn topic_name(&self) -> &str {
- self.producer_config.topic_name()
- }
}
Review Comment:
simplification: this second `impl IggyStreamConfig` block now holds only two
getters. fold them into the block above.
##########
core/sdk/src/stream_builder/build/build_stream_topic.rs:
##########
@@ -43,13 +43,14 @@ pub(crate) async fn build_iggy_stream_topic_if_not_exists(
client: &IggyClient,
config: &IggyConsumerConfig,
Review Comment:
nit: the doc above still says `IggyProducerConfig` (lines 28 and 36) but the
parameter is `IggyConsumerConfig`. line 31 also doubles "and return" and ends
in a stray "d".
##########
core/sdk/src/clients/consumer.rs:
##########
@@ -1434,7 +1434,7 @@ impl IggyConsumer {
IdKind::String => (consumer.id.get_string_value()?, None),
};
- let consumer_group_id = name.to_owned().try_into()?;
+ let consumer_group_id = Identifier::named(&name)?;
Review Comment:
simplification: `_id` from the match above is never read, and every caller
passes the same string as name and id, so `let name = consumer_name;` does the
job. drop the match and the `get_u32_value()?`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]