arrow-kt / arrow

Λrrow - Functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
6.13k stars 442 forks source link

["Request"] Resilience Saga allow #3432

Open nomisRev opened 3 months ago

nomisRev commented 3 months ago

What version are you currently using?

2.0.0-alpha.1

What would you like to see?

Similarly to nested transaction, I want to be able to automatically created nested Sagas. This can easily be done by injecting the SagaContext into the CoroutineContext, if nested sagas are configured, and any nested Saga could automatically be nested into the parent. This machinery should be internal to Resilience, so all new code to add this functionality should be private, and not inlined.

private class SagaContext(private val scope: SagaScope): CoroutineContext
private fun sagaContext(): SagaContext? = TODO()

fun <A> sagaScope(
  allowNested: Boolean = false,
  block: SagaScope.() -> A
): Saga<A> {
   ...
}