@@ -89,10 +89,11 @@ pub struct ConsumerBuilder {
89
89
pub ( crate ) offset_specification : OffsetSpecification ,
90
90
pub ( crate ) filter_configuration : Option < FilterConfiguration > ,
91
91
pub ( crate ) client_provided_name : String ,
92
+ pub ( crate ) properties : HashMap < String , String > ,
92
93
}
93
94
94
95
impl ConsumerBuilder {
95
- pub async fn build ( self , stream : & str ) -> Result < Consumer , ConsumerCreateError > {
96
+ pub async fn build ( mut self , stream : & str ) -> Result < Consumer , ConsumerCreateError > {
96
97
// Connect to the user specified node first, then look for a random replica to connect to instead.
97
98
// This is recommended for load balancing purposes
98
99
@@ -161,18 +162,17 @@ impl ConsumerBuilder {
161
162
let msg_handler = ConsumerMessageHandler ( consumer. clone ( ) ) ;
162
163
client. set_handler ( msg_handler) . await ;
163
164
164
- let mut properties = HashMap :: new ( ) ;
165
165
if let Some ( filter_input) = self . filter_configuration {
166
166
if !client. filtering_supported ( ) {
167
167
return Err ( ConsumerCreateError :: FilteringNotSupport ) ;
168
168
}
169
169
for ( index, item) in filter_input. filter_values . iter ( ) . enumerate ( ) {
170
170
let key = format ! ( "filter.{}" , index) ;
171
- properties. insert ( key, item. to_owned ( ) ) ;
171
+ self . properties . insert ( key, item. to_owned ( ) ) ;
172
172
}
173
173
174
174
let match_unfiltered_key = "match-unfiltered" . to_string ( ) ;
175
- properties. insert (
175
+ self . properties . insert (
176
176
match_unfiltered_key,
177
177
filter_input. match_unfiltered . to_string ( ) ,
178
178
) ;
@@ -184,7 +184,7 @@ impl ConsumerBuilder {
184
184
stream,
185
185
self . offset_specification ,
186
186
1 ,
187
- properties,
187
+ self . properties . clone ( ) ,
188
188
)
189
189
. await ?;
190
190
@@ -221,6 +221,11 @@ impl ConsumerBuilder {
221
221
self . filter_configuration = filter_configuration;
222
222
self
223
223
}
224
+
225
+ pub fn properties ( mut self , properties : HashMap < String , String > ) -> Self {
226
+ self . properties = properties;
227
+ self
228
+ }
224
229
}
225
230
226
231
impl Consumer {
0 commit comments