Code review: project with tokio and futures

Hi guys, I’m trying to make a program that can start multiple tcp, tcp with ssl, or udp servers with tokio and send each line to a kafka server. This was my first time interacting with Tokio and Futures. I already wasn’t too great with lifetimes, so there might be some obscure parts of the code that exist because I couldn’t find a proper solution.

Would love to have some feedback on what better practices I should do. Specifically that lazy_static config setup. I wasn’t able to pass a reference to the topic.

I also was thinking of the idea of just having the Futures from the functions returns a line which just gets sent through a function to send to kafka but I’m not sure how much that would affect performance.

You can put the config into an Rc and then pass (i.e. move) clones of it to your futures that you end up spawning on the reactor.

1 Like

Thanks! That sounds pretty useful. Was there anything about the current code that I should definitely change?

Nothing else really jumps out from a cursory glance. I’m not sure what the 'a lifetime is for in the couple of serve functions but that’s kind of minor.

1 Like