Transaction implementation question

⚓ Rust    📅 2025-12-10    👤 surdeus    👁️ 9      

surdeus

Warning

This post was published 38 days ago. The information described in this article may have changed.

Hi !

I try to implement a system of transaction.
I want to have a lot of service that have a function to pass (I call that action) and if the function fail, I revert with a function (I call that compensate).

The transaction have multiple service that must all pass in order. If one fail, we revert all services with compensate function.

In a first time, I was thinking to add a service with the two functions (action and compensate).
Finally, I think about doing that with trait.

In my example, I have only one service that just log message, but Imagine the transaction must launch multiples services to success.

I have problem to understand how to pass the problem of size not know at compilation... and the generic type that must implement Service trait...

Maybe, there other way that are more adapted to this kind of problem ?
I would like to learn advanced rust with this example.

Have you a advice for me please ?

2 posts - 2 participants

Read full topic

🏷️ Rust_feed