Skip to content

Commit

Permalink
fix clippy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePalaia committed Oct 19, 2024
1 parent 5a557a7 commit 688ea68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
14 changes: 6 additions & 8 deletions src/superstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ pub struct DefaultSuperStreamMetadata {

impl DefaultSuperStreamMetadata {
pub async fn partitions(&mut self) -> Vec<String> {
if self.partitions.len() == 0 {
if self.partitions.is_empty() {
println!("partition len is 0");
let response = self.client.partitions(self.super_stream.clone()).await;

self.partitions = response.unwrap().streams;
}
return self.partitions.clone();
self.partitions.clone()
}
pub async fn routes(&mut self, routing_key: String) -> Vec<String> {
if self.routes.len() == 0 {
if self.routes.is_empty() {
let response = self
.client
.route(routing_key, self.super_stream.clone())
Expand All @@ -32,7 +32,7 @@ impl DefaultSuperStreamMetadata {
self.routes = response.unwrap().streams;
}

return self.routes.clone();
self.routes.clone()
}
}

Expand All @@ -49,9 +49,7 @@ impl RoutingKeyRoutingStrategy {
) -> Vec<String> {
let key = (self.routing_extractor)(message);

let routes = metadata.routes(key).await;

return routes;
metadata.routes(key).await
}
}

Expand All @@ -78,7 +76,7 @@ impl HashRoutingMurmurStrategy {
let stream = partitions.into_iter().nth(route as usize).unwrap();
streams.push(stream);

return streams;
streams
}
}

Expand Down
17 changes: 7 additions & 10 deletions src/superstream_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl SuperStreamProducer<NoDedup> {
}

let producer = self.1.get(route.as_str()).unwrap();
let _ = producer.send(message.clone(), cb.clone()).await?;
producer.send(message.clone(), cb.clone()).await?;
}
Ok(())
}
Expand All @@ -79,19 +79,16 @@ impl SuperStreamProducer<NoDedup> {
let mut is_error = false;
for (_, producer) in self.1.into_iter() {
let close = producer.close().await;
match close {
Err(e) => {
is_error = true;
err = Some(e);
}
_ => (),
if let Err(e) = close {
is_error = true;
err = Some(e);
}
}

if is_error == false {
return Ok(());
if !is_error {
Ok(())
} else {
return Err(err.unwrap());
Err(err.unwrap())
}
}
}
Expand Down

0 comments on commit 688ea68

Please sign in to comment.