lundi 21 mars 2022

Rust async but with sequential execution?

TL;DR, can you please share your tips to get a easy-to-read / maintain code, "sequential like" with async rust ?

I am using rust for a while now for fun and at work. My main goal recently is to develop programs that are easy to maintain and where each new commit has few chance to include bug.
Also, I am more and more working with progamming paradigms like Onion / hexagonal architecture and DDD.

To conclude with my context, I am not developping web app where I have to achieve high concurrency, although my code is using Inter-process communication through ROS.

I really enjoy async rust, but I am having troubles to avoid spagethi code...

Do you know any technology / pattern / ... which could help me to get clean code as it would be in a full sync and sequential one?

Do not hesitate to ask question here as I am not really confident about my ability to explain my ideas right :-)

See you.

The typical stuff I want to minimize is the typical "I send data over this channel through sender_x... to continue the reading of my code execution, I now have to find where receiver_x is" (same with actors).

Also, I like to describe my code as workflows as in : order_received.validate_feasibility()?.execute_order()?.send_result_to_anyone_interrested()? Finally, I like to use statemachines as it makes code really easily comprehensible in few secs to anyone reading it.

But... AS soon as I come to async, I have trouble to achieve what's described here.

Aucun commentaire:

Enregistrer un commentaire