Closed Abdullahsab3 closed 2 months ago
The current implementation of the kafka_consumer macro can be a bit unclear to use or debug. Now, it works as follows:
kafka_consumer
let consumer = kafka_consumer!( topic = KafkaTopic { name: "test".to_string(), content_type: ContentType::Json }, dlq_topic = KafkaTopic { name: "test-dlq".to_string(), content_type: ContentType::Json }, consumer_group_id = "test-group", bootstrap_servers = bootstrap_servers, handlers = [ EntityCreatedEventHandler -> EntityCreatedEventHandler {} ] );
However it would be much simpler to maintain if the handlers definitions match a little bit how Rust declares new variables. That is:
handlers
let consumer = kafka_consumer!( topic = KafkaTopic { name: "test".to_string(), content_type: ContentType::Json }, dlq_topic = KafkaTopic { name: "test-dlq".to_string(), content_type: ContentType::Json }, consumer_group_id = "test-group", bootstrap_servers = bootstrap_servers, handlers = { entity_created_event_handler: EntityCreatedEventHandler = EntityCreatedEventHandler {} } );
This would elminate the need for generate_handler_types_enum and for the handlers vector, and it would make it possible to have the entire handlers implementation done statically at compile time, without the need for the heap (vector)
generate_handler_types_enum
The current implementation of the
kafka_consumer
macro can be a bit unclear to use or debug. Now, it works as follows:However it would be much simpler to maintain if the
handlers
definitions match a little bit how Rust declares new variables. That is:This would elminate the need for
generate_handler_types_enum
and for the handlers vector, and it would make it possible to have the entire handlers implementation done statically at compile time, without the need for the heap (vector)