@@ -18,6 +18,7 @@ use std::collections::HashMap;
18
18
use std:: collections:: HashSet ;
19
19
use std:: sync:: Arc ;
20
20
21
+ use cheetah_string:: CheetahString ;
21
22
use parking_lot:: Mutex ;
22
23
use parking_lot:: RwLock ;
23
24
use rocketmq_common:: common:: consumer:: consume_from_where:: ConsumeFromWhere ;
@@ -34,8 +35,8 @@ use crate::client::client_channel_info::ClientChannelInfo;
34
35
35
36
#[ derive( Debug , Clone ) ]
36
37
pub struct ConsumerGroupInfo {
37
- group_name : String ,
38
- subscription_table : Arc < RwLock < HashMap < String , SubscriptionData > > > ,
38
+ group_name : CheetahString ,
39
+ subscription_table : Arc < RwLock < HashMap < CheetahString , SubscriptionData > > > ,
39
40
channel_info_table : Arc < RwLock < HashMap < Channel , ClientChannelInfo > > > ,
40
41
consume_type : Arc < RwLock < ConsumeType > > ,
41
42
message_model : Arc < RwLock < MessageModel > > ,
@@ -45,13 +46,13 @@ pub struct ConsumerGroupInfo {
45
46
46
47
impl ConsumerGroupInfo {
47
48
pub fn new (
48
- group_name : String ,
49
+ group_name : impl Into < CheetahString > ,
49
50
consume_type : ConsumeType ,
50
51
message_model : MessageModel ,
51
52
consume_from_where : ConsumeFromWhere ,
52
53
) -> Self {
53
54
ConsumerGroupInfo {
54
- group_name,
55
+ group_name : group_name . into ( ) ,
55
56
subscription_table : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
56
57
channel_info_table : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
57
58
consume_type : Arc :: new ( RwLock :: new ( consume_type) ) ,
@@ -61,9 +62,9 @@ impl ConsumerGroupInfo {
61
62
}
62
63
}
63
64
64
- pub fn with_group_name ( group_name : String ) -> Self {
65
+ pub fn with_group_name ( group_name : impl Into < CheetahString > ) -> Self {
65
66
ConsumerGroupInfo {
66
- group_name,
67
+ group_name : group_name . into ( ) ,
67
68
subscription_table : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
68
69
channel_info_table : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
69
70
consume_type : Arc :: new ( RwLock :: new ( ConsumeType :: ConsumePassively ) ) ,
@@ -83,7 +84,7 @@ impl ConsumerGroupInfo {
83
84
None
84
85
}
85
86
86
- pub fn get_subscription_table ( & self ) -> Arc < RwLock < HashMap < String , SubscriptionData > > > {
87
+ pub fn get_subscription_table ( & self ) -> Arc < RwLock < HashMap < CheetahString , SubscriptionData > > > {
87
88
Arc :: clone ( & self . subscription_table )
88
89
}
89
90
@@ -101,7 +102,7 @@ impl ConsumerGroupInfo {
101
102
channel_info_table. keys ( ) . cloned ( ) . collect ( )
102
103
}
103
104
104
- pub fn get_all_client_ids ( & self ) -> Vec < String > {
105
+ pub fn get_all_client_ids ( & self ) -> Vec < CheetahString > {
105
106
let channel_info_table = self . channel_info_table . read ( ) ;
106
107
channel_info_table
107
108
. values ( )
@@ -195,7 +196,7 @@ impl ConsumerGroupInfo {
195
196
196
197
pub fn update_subscription ( & self , sub_list : & HashSet < SubscriptionData > ) -> bool {
197
198
let mut updated = false ;
198
- let mut topic_set: HashSet < String > = HashSet :: new ( ) ;
199
+ let mut topic_set = HashSet :: new ( ) ;
199
200
200
201
let mut subscription_table = self . subscription_table . write ( ) ;
201
202
for sub in sub_list. iter ( ) {
@@ -238,7 +239,7 @@ impl ConsumerGroupInfo {
238
239
updated
239
240
}
240
241
241
- pub fn get_subscribe_topics ( & self ) -> HashSet < String > {
242
+ pub fn get_subscribe_topics ( & self ) -> HashSet < CheetahString > {
242
243
let subscription_table = self . subscription_table . read ( ) ;
243
244
subscription_table. keys ( ) . cloned ( ) . collect ( )
244
245
}
@@ -266,7 +267,7 @@ impl ConsumerGroupInfo {
266
267
* message_model_lock = message_model;
267
268
}
268
269
269
- pub fn get_group_name ( & self ) -> & String {
270
+ pub fn get_group_name ( & self ) -> & CheetahString {
270
271
& self . group_name
271
272
}
272
273
@@ -395,8 +396,8 @@ mod tests {
395
396
396
397
let mut sub_list = HashSet :: new ( ) ;
397
398
let subscription_data = SubscriptionData {
398
- topic : "topic" . to_string ( ) ,
399
- sub_string : "sub_string" . to_string ( ) ,
399
+ topic : "topic" . into ( ) ,
400
+ sub_string : "sub_string" . into ( ) ,
400
401
..Default :: default ( )
401
402
} ;
402
403
sub_list. insert ( subscription_data) ;
0 commit comments