I happened to see mutableSideEffect
when I was working with sideEffect
in Java SDK. Reading documentations and asking ChatGPT made me confused.
In my understanding, sideEffect
gets computed only once and the same result gets reused across workflow replay to maintain determinism.
As for mutableSideEffect
, this feature supports recomputation of the effect when the given condition is true
. My questions are:
- What kind of use cases would require
mutableSideEffect
? - When a workflow gets replayed at runtime and the
mutableSideEffect
happens to be recomputed to a new value that is different from the original result, this might cause the workflow to take a new path and produce different events from the ones in Event History. I believe this would cause non-determinism error, meaning themutable
part is not usable at all? Then why do we have this feature?
I’d be very grateful if someone could explain mutableSideEffect
to me