Skip to content

Commit c113d34

Browse files
committed
test optimization
1 parent 028f7e9 commit c113d34

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/superstream.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ pub struct DefaultSuperStreamMetadata {
1414
}
1515

1616
impl DefaultSuperStreamMetadata {
17-
pub async fn partitions(&mut self) -> Vec<String> {
17+
pub async fn partitions(&mut self) -> &Vec<String> {
1818
if self.partitions.is_empty() {
1919
let response = self.client.partitions(self.super_stream.clone()).await;
2020

2121
self.partitions = response.unwrap().streams;
2222
}
23-
self.partitions.clone()
23+
&self.partitions
2424
}
25-
pub async fn routes(&mut self, routing_key: String) -> Vec<String> {
25+
pub async fn routes(&mut self, routing_key: String) -> &Vec<String> {
2626
if !self.routes.contains_key(&routing_key) {
2727
let response = self
2828
.client
@@ -33,7 +33,7 @@ impl DefaultSuperStreamMetadata {
3333
.insert(routing_key.clone(), response.unwrap().streams);
3434
}
3535

36-
self.routes.get(routing_key.as_str()).unwrap().clone()
36+
&self.routes.get(routing_key.as_str()).unwrap()
3737
}
3838
}
3939

@@ -50,7 +50,8 @@ impl RoutingKeyRoutingStrategy {
5050
) -> Vec<String> {
5151
let key = (self.routing_extractor)(message);
5252

53-
metadata.routes(key).await
53+
metadata.routes(key).await.clone()
54+
5455
}
5556
}
5657

@@ -75,7 +76,7 @@ impl HashRoutingMurmurStrategy {
7576
let route = hash_result.unwrap() % number_of_partitions as u32;
7677

7778
let stream = partitions.into_iter().nth(route as usize).unwrap();
78-
streams.push(stream);
79+
streams.push(stream.clone());
7980

8081
streams
8182
}

0 commit comments

Comments
 (0)