@@ -21,7 +21,6 @@ use crate::handlers::TENANT_ID;
2121use aws_config:: default_provider:: region:: DefaultRegionChain ;
2222use aws_msk_iam_sasl_signer:: generate_auth_token;
2323use aws_types:: region:: Region ;
24- use derive_more:: Constructor ;
2524use rdkafka:: client:: OAuthToken ;
2625use rdkafka:: consumer:: { ConsumerContext , Rebalance } ;
2726use rdkafka:: error:: KafkaResult ;
@@ -118,13 +117,17 @@ impl RebalanceEvent {
118117 }
119118}
120119
121- #[ derive( Constructor , Serialize , Deserialize , Debug , Default , Clone , PartialEq , Eq , Hash ) ]
120+ #[ derive( Serialize , Deserialize , Debug , Default , Clone , PartialEq , Eq , Hash ) ]
122121pub struct TopicPartition {
123122 pub topic : String ,
124123 pub partition : i32 ,
125124}
126125
127126impl TopicPartition {
127+ pub const fn new ( topic : String , partition : i32 ) -> Self {
128+ Self { topic, partition }
129+ }
130+
128131 pub fn from_kafka_msg ( msg : & BorrowedMessage ) -> Self {
129132 Self :: new ( msg. topic ( ) . to_owned ( ) , msg. partition ( ) )
130133 }
@@ -134,12 +137,16 @@ impl TopicPartition {
134137 }
135138}
136139
137- #[ derive( Constructor , Serialize , Deserialize , Debug , Default , Clone , PartialEq , Eq , Hash ) ]
140+ #[ derive( Serialize , Deserialize , Debug , Default , Clone , PartialEq , Eq , Hash ) ]
138141pub struct TopicPartitionList {
139142 pub tpl : Vec < TopicPartition > ,
140143}
141144
142145impl TopicPartitionList {
146+ pub const fn new ( tpl : Vec < TopicPartition > ) -> Self {
147+ Self { tpl }
148+ }
149+
143150 pub fn from_rdkafka_tpl ( tpl : & rdkafka:: topic_partition_list:: TopicPartitionList ) -> Self {
144151 let elements = tpl. elements ( ) ;
145152 let mut tp_vec = Vec :: with_capacity ( elements. len ( ) ) ;
@@ -155,7 +162,7 @@ impl TopicPartitionList {
155162 }
156163}
157164
158- #[ derive( Constructor , Debug , Hash , Eq , PartialEq ) ]
165+ #[ derive( Debug , Hash , Eq , PartialEq ) ]
159166pub struct ConsumerRecord {
160167 pub payload : Option < Vec < u8 > > ,
161168 pub key : Option < Vec < u8 > > ,
@@ -167,6 +174,26 @@ pub struct ConsumerRecord {
167174}
168175
169176impl ConsumerRecord {
177+ pub const fn new (
178+ payload : Option < Vec < u8 > > ,
179+ key : Option < Vec < u8 > > ,
180+ topic : String ,
181+ partition : i32 ,
182+ offset : i64 ,
183+ timestamp : Option < i64 > ,
184+ tenant_id : Option < String > ,
185+ ) -> Self {
186+ Self {
187+ payload,
188+ key,
189+ topic,
190+ partition,
191+ offset,
192+ timestamp,
193+ tenant_id,
194+ }
195+ }
196+
170197 pub fn from_borrowed_msg ( msg : BorrowedMessage ) -> Self {
171198 let tenant_id = if let Some ( headers) = extract_headers ( & msg)
172199 && let Some ( tenant_id) = headers. get ( TENANT_ID )
0 commit comments