Mervyn McCreight
03/06/2024, 4:07 PMsimon.vergauwen
03/06/2024, 5:24 PMeither {
saga {
saga({ println("Action A") }) { println("Rollback A") }
raise("failed")
1
}.transact()
}
There is however a big difference between either { saga { } } or saga { either { } }. The first is a computation that can fail with E, which inside is using a saga. Since Saga sees raise as a failure, it will rollback action A.
In the latter case, we have a Saga that computes an Either. So any Left.bind, or raise, that is encountered will not fail the Saga but would return Either.Left if transact is called on the Saga.
Hope that helps! I think we should probably add this example to the documentation โบ๏ธ I find it really neat that all DSLs can be nested, and that depending on the order you can get different behavior.Mervyn McCreight
03/06/2024, 5:28 PMparMap, ...simon.vergauwen
03/06/2024, 5:31 PMMervyn McCreight
03/07/2024, 2:59 PMsimon.vergauwen
03/07/2024, 3:11 PM