@@ -14,15 +14,15 @@ pub struct DefaultSuperStreamMetadata {
14
14
}
15
15
16
16
impl DefaultSuperStreamMetadata {
17
- pub async fn partitions ( & mut self ) -> Vec < String > {
17
+ pub async fn partitions ( & mut self ) -> & Vec < String > {
18
18
if self . partitions . is_empty ( ) {
19
19
let response = self . client . partitions ( self . super_stream . clone ( ) ) . await ;
20
20
21
21
self . partitions = response. unwrap ( ) . streams ;
22
22
}
23
- self . partitions . clone ( )
23
+ & self . partitions
24
24
}
25
- pub async fn routes ( & mut self , routing_key : String ) -> Vec < String > {
25
+ pub async fn routes ( & mut self , routing_key : String ) -> & Vec < String > {
26
26
if !self . routes . contains_key ( & routing_key) {
27
27
let response = self
28
28
. client
@@ -33,7 +33,7 @@ impl DefaultSuperStreamMetadata {
33
33
. insert ( routing_key. clone ( ) , response. unwrap ( ) . streams ) ;
34
34
}
35
35
36
- self . routes . get ( routing_key. as_str ( ) ) . unwrap ( ) . clone ( )
36
+ & self . routes . get ( routing_key. as_str ( ) ) . unwrap ( )
37
37
}
38
38
}
39
39
@@ -50,7 +50,8 @@ impl RoutingKeyRoutingStrategy {
50
50
) -> Vec < String > {
51
51
let key = ( self . routing_extractor ) ( message) ;
52
52
53
- metadata. routes ( key) . await
53
+ metadata. routes ( key) . await . clone ( )
54
+
54
55
}
55
56
}
56
57
@@ -75,7 +76,7 @@ impl HashRoutingMurmurStrategy {
75
76
let route = hash_result. unwrap ( ) % number_of_partitions as u32 ;
76
77
77
78
let stream = partitions. into_iter ( ) . nth ( route as usize ) . unwrap ( ) ;
78
- streams. push ( stream) ;
79
+ streams. push ( stream. clone ( ) ) ;
79
80
80
81
streams
81
82
}
0 commit comments